Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init documentation typo "may be return" > "may NOT be returned" #70666

Closed
samuelcolvin mannequin opened this issue Mar 4, 2016 · 3 comments
Closed

Init documentation typo "may be return" > "may NOT be returned" #70666

samuelcolvin mannequin opened this issue Mar 4, 2016 · 3 comments
Labels
docs Documentation in the Doc dir

Comments

@samuelcolvin
Copy link
Mannequin

samuelcolvin mannequin commented Mar 4, 2016

BPO 26479
Nosy @ronaldoussoren, @samuelcolvin

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-04-03.10:35:01.673>
created_at = <Date 2016-03-04.13:14:18.679>
labels = ['invalid', 'docs']
title = 'Init documentation typo "may be return" > "may NOT be returned"'
updated_at = <Date 2016-04-03.10:35:01.672>
user = 'https://github.com/samuelcolvin'

bugs.python.org fields:

activity = <Date 2016-04-03.10:35:01.672>
actor = 'samuelcolvin'
assignee = 'docs@python'
closed = True
closed_date = <Date 2016-04-03.10:35:01.673>
closer = 'samuelcolvin'
components = ['Documentation']
creation = <Date 2016-03-04.13:14:18.679>
creator = 'samuelcolvin'
dependencies = []
files = []
hgrepos = []
issue_num = 26479
keywords = []
message_count = 3.0
messages = ['261185', '261186', '262823']
nosy_count = 3.0
nosy_names = ['ronaldoussoren', 'docs@python', 'samuelcolvin']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue26479'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

@samuelcolvin
Copy link
Mannequin Author

samuelcolvin mannequin commented Mar 4, 2016

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__();"

@samuelcolvin samuelcolvin mannequin assigned docspython Mar 4, 2016
@samuelcolvin samuelcolvin mannequin added the docs Documentation in the Doc dir label Mar 4, 2016
@ronaldoussoren
Copy link
Contributor

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.

@samuelcolvin
Copy link
Mannequin Author

samuelcolvin mannequin commented Apr 3, 2016

Sorry, I'm going mad, misread it.

@samuelcolvin samuelcolvin mannequin closed this as completed Apr 3, 2016
@samuelcolvin samuelcolvin mannequin added the invalid label Apr 3, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant