Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-91485: Doc: Using Python syntax to document builtin Python functions.#96579
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-91485: Doc: Using Python syntax to document builtin Python functions.#96579
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
JulienPalard commentedSep 21, 2022
I don't like: for an acute reader it scream "the default empty list is reused!", I have to change this. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Antoine Rozo <antoine.rozo@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
AA-Turner left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Biggest comment is onmap().
A
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Doc/library/functions.rst Outdated
| ..function::map(function,*iterables) | ||
| Return an iterator that applies *function* to every item of *iterable*, | ||
| yielding the results. If additional *iterable* arguments are passed, | ||
| Return an iterator that applies *function* to every item of *iterables*, | ||
| yielding the results. If additional *iterables* arguments are passed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't think the new wording is true, e.g.:
>>>from operatorimport add>>>for xinmap(add, [1,2,3,4,5], [10,20,30,40,50]):>>>print(x)>>> 1122334455
So it doesn't applyfunction to every item ofiterables, but to every item ofzip(*iterables).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
you're right, we have to rephrase it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about7aca0e5 ?map(int) is not valid anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(I move the / in the following commit asiterable can't be given by name)
0bf0db5 to92a3bb0CompareJulienPalard commentedOct 13, 2022
@AA-Turner wow we were doing it in the same time, I just pushed my part, we'll be able to diff them to see if we agree :D |
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
AA-Turner left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! I think this is good to merge personally.
A
miss-islington commentedOct 15, 2022
Thanks@JulienPalard for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
miss-islington commentedOct 15, 2022
Sorry,@JulienPalard, I could not cleanly backport this to |
bedevere-bot commentedOct 15, 2022
GH-98276 is a backport of this pull request to the3.11 branch. |
…unctions. (pythonGH-96579)(cherry picked from commit3c4cbd1)Co-authored-by: Julien Palard <julien@palard.fr>
Uh oh!
There was an error while loading.Please reload this page.
I tried my idea at documenting Python functions using only Python syntax (avoiding manpages-like brackets to denote optional arguments), please tell me what you think.
It sometimes went "badly", like:
where I "had" to use an empty tuple because it would have looked very recursive to use a set here, like
set(iterable=set()). It's also a lie: it's not an empty tuple by default (it's a CNULL), but there's no practical difference for the reader.Sometimes the change is more neutral, like in:
or:
(where I'm happy to remove
, *[,because it hurt my eyes.)Sometimes it's good as it add information:
Or make more explicit where it's OK to pass
Noneand where it's not, like in:I bet you think « People should know this syntax, or learn it anyway », but I don't think so, I mean yes they will learn it anyway, but why forcing them to learn it at the same time as they learn basic Python functions? Learning one thing at a time is complicated enough.
Many are alone facing those pages and showing them:
teach them how to implement default arguments in their own functions, and explicitly show them what happen when they don't give the values, while:
don't.