Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > argparse '--' not working?

Reply
Thread Tools

argparse '--' not working?

 
 
Neal Becker
Guest
Posts: n/a
 
      11-12-2010
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: argparse '--' not working? Peter Otten Python 0 11-12-2010 01:31 PM
[ANN] argparse 0.3 - Command-line parsing library Steven Bethard Python 0 12-05-2006 05:36 PM
[ANN] argparse 0.2 - Command-line parsing library Steven Bethard Python 0 10-24-2006 04:13 PM
[ANN] argparse 0.1 - Command-line parsing library Steven Bethard Python 1 10-10-2006 11:06 PM
[ANN] The argparse module Steven Bethard Python 0 08-03-2006 05:41 AM



Advertisments