Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   argparse '--' not working? (http://www.velocityreviews.com/forums/t737840-argparse-not-working.html)

Neal Becker 11-12-2010 01:05 PM

argparse '--' not working?
 
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



All times are GMT. The time now is 11:13 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.