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

Describe use of args parameter of argparse.ArgumentParser.parse_args #59632

Closed
bethard mannequin opened this issue Jul 22, 2012 · 7 comments
Closed

Describe use of args parameter of argparse.ArgumentParser.parse_args #59632

bethard mannequin opened this issue Jul 22, 2012 · 7 comments
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@bethard
Copy link
Mannequin

bethard mannequin commented Jul 22, 2012

BPO 15427
Nosy @bitdancer, @Mariatta
PRs
  • bpo-15427 Clarify nature of parse_args 'args' argument. #3292
  • [2.7] bpo-15427 Clarify nature of parse_args 'args' argument. (GH-3292) #3328
  • [3.6] bpo-15427 Clarify nature of parse_args 'args' argument. (GH-3292) #3325
  • Files
  • remainder.patch
  • remainder.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 = <Date 2017-09-10.05:57:04.391>
    created_at = <Date 2012-07-22.22:12:33.537>
    labels = ['type-bug', '3.7', 'docs']
    title = 'Describe use of args parameter of argparse.ArgumentParser.parse_args'
    updated_at = <Date 2017-09-10.05:57:04.358>
    user = 'https://bugs.python.org/bethard'

    bugs.python.org fields:

    activity = <Date 2017-09-10.05:57:04.358>
    actor = 'Mariatta'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2017-09-10.05:57:04.391>
    closer = 'Mariatta'
    components = ['Documentation']
    creation = <Date 2012-07-22.22:12:33.537>
    creator = 'bethard'
    dependencies = []
    files = ['29661', '29662']
    hgrepos = []
    issue_num = 15427
    keywords = ['patch']
    message_count = 7.0
    messages = ['166174', '185888', '185893', '185895', '187330', '301243', '301800']
    nosy_count = 6.0
    nosy_names = ['bethard', 'v+python', 'r.david.murray', 'docs@python', 'paul.j3', 'Mariatta']
    pr_nums = ['3292', '3328', '3325']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15427'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @bethard
    Copy link
    Mannequin Author

    bethard mannequin commented Jul 22, 2012

    From http://bugs.python.org/issue14191#msg155202:

    ArgumentParser.parse_args(args=None, namespace=None)
    ...
    However, nowhere is the args= parameter explained.  One example is given at the end of 15.4.4.6 showing the use of args= which apparently accepts a list of parameters, similar to the positional list of parameters that are used in all the other examples.  It might be nice to clarify that.

    @bethard bethard mannequin assigned docspython Jul 22, 2012
    @bethard bethard mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Jul 22, 2012
    @paulj3
    Copy link
    Mannequin

    paulj3 mannequin commented Apr 3, 2013

    The 'args=' parameter is the same as the first positional parameter used in most of the examples. That is normal Python behavior.

    15.4.4.5. Beyond sys.argv
    explains this alternative way of specifying argv.

    Still 2 bullet points could be added to 15.4.4.

    • args - A list of strings, default is sys.argv[1:] (link to 15.4.4.5.)
    • namespace - A Namespace object, default is a new Namespace (link to 15.4.4.6.)

    Maybe a 15.4.4.5. example using args=['1', '2', '3', '4'] would also be helpful.

    @paulj3
    Copy link
    Mannequin

    paulj3 mannequin commented Apr 3, 2013

    This patch to argparse.rst adds the argument points to parse_args().

    It also adds two points to the 'Upgrading optparse code' section, one about using 'nargs=argparse.REMAINDER', and other about 'parse_known_args()'.

    I'm not entirely happy with the format of the internal hyperlinks.

    @paulj3
    Copy link
    Mannequin

    paulj3 mannequin commented Apr 3, 2013

    I changed the reference to the optparse allow_interspersed_args attribute to the disable_interspersed_args() method.

    @vpython
    Copy link
    Mannequin

    vpython mannequin commented Apr 19, 2013

    These docs changes seem reasonable, from a side-by-side view (I didn't attempt to look at the formatted results of applying the patch), to better document the current behavior.

    @bitdancer
    Copy link
    Member

    I've turned this into a PR. The example was already changed in a previous checkin. I reworded the optparse porting addition to match the existing style of the list.

    @bitdancer bitdancer added the 3.7 (EOL) end of life label Sep 4, 2017
    @Mariatta
    Copy link
    Member

    Thanks, David. I merged the backport PRs. Closing this.

    @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
    3.7 (EOL) end of life docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants