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] give more meaningful argument names in argparse documentation #55385

Closed
bethard mannequin opened this issue Feb 10, 2011 · 23 comments
Closed

[doc] give more meaningful argument names in argparse documentation #55385

bethard mannequin opened this issue Feb 10, 2011 · 23 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@bethard
Copy link
Mannequin

bethard mannequin commented Feb 10, 2011

BPO 11176
Nosy @birkenfeld, @ezio-melotti, @merwok, @sandrotosi, @cjerdonek, @nanjekyejoannah, @Bonifacio2, @iritkatriel
PRs
  • bpo-11176: give more meaningful argument names in argparse documentation #26279
  • Files
  • argparse_simple_example.diff
  • issue11165-doc-fix-up-to-section-15.4.4.diff
  • 1176_minor_edits.diff
  • issue11176.patch
  • 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 = None
    created_at = <Date 2011-02-10.15:48:55.322>
    labels = ['easy', '3.8', '3.9', '3.10', 'type-feature', 'docs']
    title = '[doc] give more meaningful argument names in argparse documentation'
    updated_at = <Date 2021-05-27.22:40:14.381>
    user = 'https://bugs.python.org/bethard'

    bugs.python.org fields:

    activity = <Date 2021-05-27.22:40:14.381>
    actor = 'nanjekyejoannah'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2011-02-10.15:48:55.322>
    creator = 'bethard'
    dependencies = []
    files = ['26284', '26325', '26334', '27030']
    hgrepos = []
    issue_num = 11176
    keywords = ['patch', 'easy']
    message_count = 22.0
    messages = ['128302', '128355', '140679', '140685', '140745', '164802', '165059', '165068', '165109', '165115', '165731', '166182', '169258', '177641', '179764', '198350', '199034', '220779', '229510', '393842', '393974', '394613']
    nosy_count = 17.0
    nosy_names = ['georg.brandl', 'bethard', 'ezio.melotti', 'eric.araujo', 'sandro.tosi', 'chris.jerdonek', 'docs@python', 'marcs', 'westley.martinez', 'tshepang', 'adam.woodbeck', 'dlam', 'groodt', 'lonetwin', 'nanjekyejoannah', 'Bonifacio2', 'iritkatriel']
    pr_nums = ['26279']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue11176'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @bethard
    Copy link
    Mannequin Author

    bethard mannequin commented Feb 10, 2011

    Suggestion from a personal email:

    I personally am not keen on the foo/bar/baz examples. I
    know that you're trying to be generic but IMO it would be much easier to
    understand if you used meaningful names. Also, I think that the very
    first example you give (which does use meaningful names:-) is too
    clever. I'd suggest using something simpler: in fact I'd use exactly the
    same example that optparse uses (--file && --quiet) since that is easy
    to understand and relate to straight away, and maybe add a --line option
    that takes a list of ints (ostensibly line numbers of lines to extract
    from the file) if you want to show that argparse leaves optparse in the
    dust. And you can always show how to get actual file objects later on.

    @bethard bethard mannequin assigned docspython Feb 10, 2011
    @bethard bethard mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Feb 10, 2011
    @westleymartinez
    Copy link
    Mannequin

    westleymartinez mannequin commented Feb 11, 2011

    I agree; it's too artsy. I'll see if I can come up with a relevant and clever alternative.

    @merwok
    Copy link
    Member

    merwok commented Jul 19, 2011

    Hi Westley! Do you still have time to work on this?

    @merwok merwok added the easy label Jul 19, 2011
    @westleymartinez
    Copy link
    Mannequin

    westleymartinez mannequin commented Jul 19, 2011

    I worked on this some time ago; the problem was the size of the documentation, i.e. it was difficult to stay consistent. Do I have time for this? Yes, but I wouldn't get it done anytime soon, and the results could be anywhere from good to bad. As it stands, the documentation is fairly good, so I don't think it's imperative to fix it.

    @merwok
    Copy link
    Member

    merwok commented Jul 20, 2011

    I worked on this some time ago; the problem was the size of the
    documentation, i.e. it was difficult to stay consistent.
    I think it’s okay to improve the docs one patch at a time, starting with the simple example referenced in the first message in this bug report, and gradually improving other sections. Do you have a diff with your work, so that your efforts can serve as a base for someone else?

    Do I have time for this? Yes, but I wouldn't get it done anytime
    soon, and the results could be anywhere from good to bad.
    That’s why we do reviews :) It’s okay if you don’t have time, I’m interested in working on this some time in the future.

    @merwok merwok assigned merwok and unassigned docspython Jul 20, 2011
    @groodt
    Copy link
    Mannequin

    groodt mannequin commented Jul 7, 2012

    Is this still an issue? If so, I've created a simpler first example as suggested below.

    If we decide these docs still need a bit more work, I can also continue to provide better examples than the "foo bar" ones.

    @merwok
    Copy link
    Member

    merwok commented Jul 9, 2012

    Yep, this is still open. Thanks for the patch, I did a review (if you did not get a mail, follow the link in the list of files).

    @merwok merwok removed their assignment Jul 9, 2012
    @dlam
    Copy link
    Mannequin

    dlam mannequin commented Jul 9, 2012

    haha wow, I was working on this bug too! maybe we can work on the final patch together

    I got through about 2/3's of the docs, so I thought it might help to upload what I got so far. I basically just made stuff up so I'm totally winning to change anything (or everything)

    I made a little effort to make the examples mildly amusing, since novelty sorta helps in retention. So one of the recurring examples I used involves that of a pizza-making-program... hopefully this helps in some way!

    @groodt
    Copy link
    Mannequin

    groodt mannequin commented Jul 9, 2012

    Hi David

    Ok, I like the idea of working on a solution together. I like your idea of
    the pizza-making more than the current "foo bar" examples.

    Should we collaborate outside of the bug tracker?

    Greg

    On 9 July 2012 07:11, David Lam <report@bugs.python.org> wrote:

    David Lam <d@dlam.me> added the comment:

    haha wow, I was working on this bug too! maybe we can work on the final
    patch together

    I got through about 2/3's of the docs, so I thought it might help to
    upload what I got so far. I basically just made stuff up so I'm totally
    winning to change anything (or everything)

    I made a little effort to make the examples mildly amusing, since novelty
    sorta helps in retention. So one of the recurring examples I used involves
    that of a pizza-making-program... hopefully this helps in some way!

    ----------
    nosy: +dlam
    Added file:
    http://bugs.python.org/file26325/issue11165-doc-fix-up-to-section-15.4.4.diff


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue11176\>


    @groodt
    Copy link
    Mannequin

    groodt mannequin commented Jul 9, 2012

    I've made the minor edits required after the review to my simplification of the first example.

    David, perhaps we combine our efforts? Use my simple first example to explain the very basics, then continue the explanation with the pizza example?

    Im happy either way, I quite like your example using the system dictionary.

    @dlam
    Copy link
    Mannequin

    dlam mannequin commented Jul 17, 2012

    yup yup, go for it

    @bethard
    Copy link
    Mannequin Author

    bethard mannequin commented Jul 22, 2012

    Thanks for working on this! I think keeping the first example as simple is possible is probably a good idea. And I didn't have time to read through the whole patch, but as far as I went, the pizza examples looked great.

    @dlam
    Copy link
    Mannequin

    dlam mannequin commented Aug 28, 2012

    here's a patch that covers all but one of the foo/bar/baz examples

    it also has fixes for the sample code near the beginning from the review Ezio did

    the one example I didn't do was the "Arguments containing -" part. I guess it felt like changing the names in that example would distract from what it was trying to illustrate there

    Anyways, I tried to proofread it so hopefully it reads okay, enjoy enjoy ^^

    @cjerdonek
    Copy link
    Member

    Also see this e-mail to docs@:

    http://mail.python.org/pipermail/docs/2012-December/012028.html

    Subject: [docs] FOO and BAR

    Do you think it would be possible to write your documentation avoiding the silly usage of FOO and BAR everywhere? This is a very very old and boring joke, and does nothing to clarify what you are trying to clarify. If you could include real-world examples in your documentation, rather than "clever" programmer "jokes", learners such as myself would have far more respect for the good work you are obviously doing here.

    For example, the section on argparser is full of this sort of rubbish:
    argparse.ArgumentParser(description='A foo that bars')

    Under what circumstances would you ever put that in a program? Are you mad?

    Please take this into consideration.

    @cjerdonek
    Copy link
    Member

    bpo-16933 improved the "choices" examples.

    @westleymartinez
    Copy link
    Mannequin

    westleymartinez mannequin commented Sep 24, 2013

    I've skimmed through the patches. Good job kids. This is much better than it was before. No more of that silly command-line calculator or the foobar nonsense that sounds drier than the POSIX standard.

    Is there anything else that needs to be done?

    @birkenfeld
    Copy link
    Member

    Also see this e-mail to docs@:
    http://mail.python.org/pipermail/docs/2012-December/012028.html

    No, please don't see this e-mail. It's not worth it. The poster clearly has no clue whatsoever about either a) common placeholders, or b) manners.

    I don't want to claim that foo/bar/etc. are superior to a well-thought-out example (which takes time to come up with), but they are certainly better than no example at all.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 16, 2014

    If we've got some meaningful changes can we please get them committed. However I'd like to state that with over 4000 issues open we've got better things to do than change docs because somebody doesn't like the use of foo, bar and baz in examples.

    @lonetwin
    Copy link
    Mannequin

    lonetwin mannequin commented Oct 16, 2014

    I came here to file a bug against the argparse documentation because reading through the documentation I didn't realize a good usecase for the epilog argument to the ArgumentParser() class until I started noticing that some commandline tools end with examples of usage.

    I found this bug and so thought it would be better to just leave a comment here instead.

    I glaced through the submitted patches and noticed that the pizza making example has epilog="Remember: select a good combination to ensure maximum tastiness ...which while good, still might not immediately convey the usefulness of the epilog parameter (just IMHO). I think, the example would be better served by something like:

    >>> pizza_parser = argparse.ArgumentParser(
    ...     description='Make a pizza out of ingredients and toppings',
    ...     epilog="""Examples: Create a Python Lovers pizza using the command::
    ...     ./makepizz.py spam ham eggs
    ...     """)

    Of course this example would then also require passing a formatter_class argument to handle the wrapping ...but in essence the point of my comment is that the examples might be more useful if a 'real-world' usage is demonstrated.

    @iritkatriel iritkatriel added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Nov 6, 2020
    @iritkatriel iritkatriel changed the title give more meaningful argument names in argparse documentation [doc] give more meaningful argument names in argparse documentation Nov 6, 2020
    @Bonifacio2
    Copy link
    Mannequin

    Bonifacio2 mannequin commented May 17, 2021

    I tried applying the latest patch version but it failed. Are the original authors still interested in moving forward with this patch? If not then I could give this issue a try.

    @iritkatriel
    Copy link
    Member

    It's been over six years, go for it.

    @nanjekyejoannah
    Copy link
    Member

    Can you give the original authors some credit too on the PR, if you built on their work, please?

    We usually do it by putting co-author: <email> in the PR comment.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @DanielNoord
    Copy link
    Contributor

    #26279 was closed because a core developer thought the current documentation worked better.

    Perhaps this should be closed then?

    @iritkatriel iritkatriel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    Status: Done
    Development

    No branches or pull requests

    6 participants