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.

classification
Title: Init documentation typo "may be return" > "may NOT be returned"
Type: Stage:
Components: Documentation Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ronaldoussoren, samuelcolvin
Priority: normal Keywords:

Created on 2016-03-04 13:14 by samuelcolvin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg261185 - (view) Author: Samuel Colvin (samuelcolvin) * Date: 2016-03-04 13:14
https://docs.python.org/3/reference/datamodel.html#object.__init__

"no non-None value may be returned by __init__();" should read "no non-None value may *not* be returned by __init__();"
msg261186 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2016-03-04 13:23
The text appears to be correct as it is. What is says is that __init__ must not return any value other than None and that is correct, you will get an exception when you return a value that is not None.

>>> class C():
...    def __init__(self): return 42
... 
>>> 
>>> C()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() should return None, not 'int'
>>> 

The text is basically a language-lawyer way of stating that __init__ should return by either running of the end of the method, or by using a bare return statement.
msg262823 - (view) Author: Samuel Colvin (samuelcolvin) * Date: 2016-04-03 10:35
Sorry, I'm going mad, misread it.
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70666
2016-04-03 10:35:01samuelcolvinsetstatus: open -> closed
resolution: not a bug
messages: + msg262823
2016-03-04 13:23:15ronaldoussorensetnosy: + ronaldoussoren
messages: + msg261186
2016-03-04 13:14:18samuelcolvincreate