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

[doc] Replace super(XXX, self) with super() in code examples #22314

Merged
merged 1 commit into from Apr 26, 2021

Conversation

andresdelfino
Copy link
Contributor

@andresdelfino andresdelfino commented Sep 18, 2020

As it is documented, it can make one think passing args to super() in these cases is needed, which is misleading.

@andresdelfino andresdelfino requested review from 1st1 and vsajip as code owners Sep 18, 2020
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels Sep 18, 2020
@vsajip vsajip changed the title [doc] Use super 0-args form when passing args is not needed [doc] Replace super(XXX, self) with super() in code examples Sep 19, 2020
Copy link
Member

@vsajip vsajip left a comment

For my part, I don't mind leaving the old form in, because it works for both newer and older versions of Python. Someone copy-pasting from a cookbook might not be well-versed in Python, and there's no reason to trip them up in case they paste into a project using an older Python version.

@andresdelfino
Copy link
Contributor Author

andresdelfino commented Sep 19, 2020

For my part, I don't mind leaving the old form in, because it works for both newer and older versions of Python. Someone copy-pasting from a cookbook might not be well-versed in Python, and there's no reason to trip them up in case they paste into a project using an older Python version.

I can see your point, but I think that goes against new (3.x) users. Imagine having all classes in examples explicitly subclassing object so that Python 2 users can copy & paste. Perhaps I'm missing something, but it seems the same thing to me. Plus, the reason that "this is for Python 2 users to be able to copy & paste" isn't obvious to a Python 3 user that's reading the code, so she/he may get the wrong idea, and understand that in those cases it's necessary to do things that way.

super() can be complex, so showing it as simple as it gets in the simple cases seems better to me.

@iritkatriel
Copy link
Member

iritkatriel commented Sep 28, 2020

I agree with both of your comments, but since the logging-cookbook is versioned - wouldn't it be ok to update the Python 3 branches without backporting to the python 2.7 version?

@andresdelfino
Copy link
Contributor Author

andresdelfino commented Sep 28, 2020

I agree with both of your comments, but since the logging-cookbook is versioned - wouldn't it be ok to update the Python 3 branches without backporting to the python 2.7 version?

Yes, this shouldn't be backported to 2.7

@vsajip
Copy link
Member

vsajip commented Sep 29, 2020

OK, I don't feel that strongly about it, so I'm OK with making these changes in the logging cookbook. Not sure how authors of the other files affected feel - I think we should be consistent across all these files.

@andresdelfino
Copy link
Contributor Author

andresdelfino commented Oct 11, 2020

@1st1 Could you talk a look at this when you have some time? :)

@orsenthil
Copy link
Member

orsenthil commented Apr 26, 2021

I find it preferable to use the zero-argument form of super in Python 3.0 docs as there reference document in 3.0 and linked documents demonstrate that form only ( https://docs.python.org/3/library/functions.html#super)

  • If we have to showcase the two argument form, the reference document could be enhanced.

+1 to this patch, and using super() directly for the superclasses. I reviewed all the examples and it looks good to me.

@orsenthil orsenthil merged commit 52cd6d5 into python:master Apr 26, 2021
3 checks passed
@miss-islington
Copy link
Contributor

miss-islington commented Apr 26, 2021

Thanks @andresdelfino for the PR, and @orsenthil for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 26, 2021
…ythonGH-22314)

(cherry picked from commit 52cd6d5)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
@bedevere-bot
Copy link

bedevere-bot commented Apr 26, 2021

GH-25638 is a backport of this pull request to the 3.9 branch.

@bedevere-bot
Copy link

bedevere-bot commented Apr 26, 2021

GH-25639 is a backport of this pull request to the 3.8 branch.

orsenthil pushed a commit that referenced this pull request Apr 26, 2021
…H-22314) (GH-25639)

(cherry picked from commit 52cd6d5)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
orsenthil pushed a commit that referenced this pull request Apr 26, 2021
…H-22314) (GH-25638)

(cherry picked from commit 52cd6d5)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
@andresdelfino andresdelfino deleted the use_super_0args_form branch Apr 26, 2021
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 skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants