About 5,700,000 results
Open links in new tab
  1. What's the best way to parse command line arguments?

    What's the easiest, tersest, and most flexible method or library for parsing Python command line arguments?

  2. python - How to use argparse subparsers correctly? - Stack Overflow

    a_parser.add_argument("something", choices=['a1', 'a2']) Since -v is defined for the main parser, it must be specified before the argument that specifies which subparser is used for the remaining arguments.

  3. python - argparse mutual exclusive group - Stack Overflow

    parser.add_argument("-a", "--aggregation", help="aggregation") I am using here options given to a command line wrapper for querying a mongodb. The collection instance can either call the method …

  4. How can I parse (read) and use JSON in Python? - Stack Overflow

    My Python program receives JSON data, and I need to get bits of information out of it. How can I parse the data and use the result? I think I need to use json.loads for this task, but I can't under...

  5. How to handle variable number of arguments (nargs='*')

    The relevant Python bug is Issue 15112. argparse: nargs='*' positional argument doesn't accept any items if preceded by an option and another positional When argparse parses ['1', '2', '--spam', '8', '8', …

  6. How to parse multiple nested sub-commands using python argparse?

    import argparse ## This function takes the 'extra' attribute from global namespace and ## re-parses it to create separate namespaces for all other chained commands. def parse_extra (parser, namespace): …

  7. python - How can I parse XML and get instances of a particular node ...

    Python has an interface to the expat XML parser. xml.parsers.expat It's a non-validating parser, so bad XML will not be caught. But if you know your file is correct, then this is pretty good, and you'll …

  8. Which tool to use to parse programming languages in Python?

    Apr 12, 2017 · Which Python tool can you recommend to parse programming languages? It should allow for a readable representation of the language grammar inside the source. It should also be able to …

  9. How can I pass a list as a command-line argument with argparse?

    I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option? parser.add_argument('-l', '--list', type=list, acti...

  10. python - Argparse optional positional arguments? - Stack Overflow

    $ python myfile.py Installing to /users/myname/myfolder $ python myfile.py /usr/bin/ Installing to /usr/bin Longer answer Since you also mention the flag-style True/False options -h and -v in your question, …