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: argparse uses "container object", should be "iterable"
Type: Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: eric.smith, shireenrao
Priority: normal Keywords: newcomer friendly, patch

Created on 2019-08-08 13:30 by eric.smith, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15178 closed shireenrao, 2019-08-08 14:38
Messages (8)
msg349234 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-08 13:30
https://docs.python.org/3/library/argparse.html#choices says "These can be handled by passing a container object as the choices keyword argument to add_argument()".

I think this should be "iterable" instead. Internally, argparse reads the iterable and converts it to a list so that it can read it multiple times (among other reasons, I'm sure). One of the examples uses range(), which is not a container.

"container" is also used in https://docs.python.org/3/library/argparse.html#the-add-argument-method

Bonus points for fixing the docstring in argparse.py. I didn't check if anywhere else in that file needs to be fixed.
msg349235 - (view) Author: Srinivas Nyayapati (shireenrao) * Date: 2019-08-08 14:06
Can I work on this?
msg349236 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-08 14:15
shireenrao: yes, please! As they say, PR's accepted!

I'll warn you that I think the only way this could become newcomer-unfriendly is if there are objections that "iterable" is too much jargon for the argparse documentation. But I'll argue that there's a separate tutorial for beginners, and that the documentation should be precise.
msg349237 - (view) Author: Srinivas Nyayapati (shireenrao) * Date: 2019-08-08 14:40
Done. Thank you.
msg349238 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-08 14:50
Actually, I might have mislead you on this. I now think that plain iterators won't work. I'm still researching this, I'll get back to you on it. I apologize if it turns out I wasted your time.
msg349239 - (view) Author: Srinivas Nyayapati (shireenrao) * Date: 2019-08-08 14:56
Not at all. I just started contributing to cpython 2 days ago and finally got the hang of it and was able to push this without any issues on my side. So either way I would still call this a win for me :)
msg349245 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-08 18:31
Sorry, shireenrao, but I'm closing this. It's entirely my error: I misread the source where it was converting this to a list.

The requirement is really that it be something you can iterate over multiple times, and supports "in". I guess "container object" is as good as anything for that.

Again, sorry to waste your time, but I'm glad you got something out of the experience. If you're working on another issue and need some help or a review, please let me know.

Can you close your PR, or do you want me to?
msg349249 - (view) Author: Srinivas Nyayapati (shireenrao) * Date: 2019-08-08 19:15
I understand eric.smith. I can close this PR. 

I currently have the following 3 other PR's waiting for review on github -
https://github.com/python/cpython/pull/15180
https://github.com/python/cpython/pull/15170
https://github.com/python/cpython/pull/15149

Would appreciate it if you could take a look :)
History
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81974
2019-08-08 19:15:03shireenraosetmessages: + msg349249
2019-08-08 18:31:06eric.smithsetstatus: open -> closed

nosy: - docs@python
messages: + msg349245

resolution: not a bug
stage: patch review -> resolved
2019-08-08 14:56:55shireenraosetmessages: + msg349239
2019-08-08 14:50:59eric.smithsetmessages: + msg349238
2019-08-08 14:40:46shireenraosetmessages: + msg349237
2019-08-08 14:38:39shireenraosetkeywords: + patch
stage: patch review
pull_requests: + pull_request14909
2019-08-08 14:15:06eric.smithsetmessages: + msg349236
2019-08-08 14:06:04shireenraosetnosy: + shireenrao
messages: + msg349235
2019-08-08 13:30:55eric.smithcreate