argparse '--' not working?

Discussion in 'Python' started by Neal Becker, Nov 12, 2010.

  1. Neal Becker

    Neal Becker Guest

    It is a 'standard' behaviour that a lone '--' terminates options. argparse
    says:

    If you have positional arguments that must begin with '-' and don’t look
    like negative numbers, you can insert the pseudo-argument '--' which tells
    parse_args that everything after that is a positional argument:

    But it doesn't seem to work:

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument ('--submit', '-s', action='store_true')
    parser.add_argument ('--list', '-l', action='store_true')
    opt = parser.parse_args()

    ../queue --submit -- test1.py -n
    usage: queue [-h] [--submit] [--list]
    queue: error: unrecognized arguments: -- test1.py -n
     
    Neal Becker, Nov 12, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Bethard

    [ANN] The argparse module

    Steven Bethard, Aug 3, 2006, in forum: Python
    Replies:
    0
    Views:
    800
    Steven Bethard
    Aug 3, 2006
  2. Steven Bethard
    Replies:
    1
    Views:
    278
    Steven Bethard
    Oct 11, 2006
  3. Steven Bethard
    Replies:
    0
    Views:
    271
    Steven Bethard
    Oct 24, 2006
  4. Steven Bethard
    Replies:
    0
    Views:
    287
    Steven Bethard
    Dec 5, 2006
  5. Peter Otten

    Re: argparse '--' not working?

    Peter Otten, Nov 12, 2010, in forum: Python
    Replies:
    0
    Views:
    464
    Peter Otten
    Nov 12, 2010
Loading...

Share This Page