This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Dict creation with update will result to NoneType
Type: behavior Stage: resolved
Components: Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, serhiy.storchaka, thedemz
Priority: normal Keywords:

Created on 2017-11-25 22:56 by thedemz, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg306977 - (view) Author: Martin (thedemz) Date: 2017-11-25 22:56
>>> x = {"x":123}.update({"abc":123})
>>> type(x)
<class 'NoneType'>
msg306978 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-11-25 23:07
dict.update() returns None, so this is expected. Maybe you want:

>>> x = {"X":123}
>>> x.update({"abc":123})
>>> x
{'X': 123, 'abc': 123}
msg306979 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-25 23:14
The update() method returns None. This is a correct behavior.

The rationale is the same as for list.sort(), see
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76316
2017-11-25 23:14:09serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg306979
2017-11-25 23:07:44eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg306978

resolution: not a bug
stage: resolved
2017-11-25 22:56:23thedemzcreate