[issue26479] Init documentation typo "may be return" > "may NOT be returned"

New submission from Samuel Colvin: 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__();" ---------- assignee: docs@python components: Documentation messages: 261185 nosy: Samuel Colvin, docs@python priority: normal severity: normal status: open title: Init documentation typo "may be return" > "may NOT be returned" versions: Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26479> _______________________________________

Ronald Oussoren added the comment: 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. ---------- nosy: +ronaldoussoren _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26479> _______________________________________

Samuel Colvin added the comment: Sorry, I'm going mad, misread it. ---------- resolution: -> not a bug status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26479> _______________________________________
participants (2)
-
Ronald Oussoren
-
Samuel Colvin