On 15.05.2013 14:24, Roy Smith wrote:
In article <kmva9j$1hbk$1...@gwdu112.gwdg.de>,
Henry Leyh <henry.l...@ipp.mpg.de> wrote:
Is there a simple way to determine which
command line arguments were actually given on the commandline, i.e. does
argparse.ArgumentParser() know which of its namespace members were
actually hit during parse_args().
I think what you're looking for is sys.argv:
$ cat argv.py
import sys
print sys.argv
$ python argv.py foo bar
['argv.py', 'foo', 'bar']
Thanks, but as I wrote in my first posting I am aware of sys.argv and
was hoping to _avoid_ using it because I'd then have to kind of
re-implement a lot of the stuff already there in argparse, e.g. parsing
sys.argv for short/long options, flag/parameter options etc.
I was thinking of maybe some sort of flag that argparse sets on those
optional arguments created with add_argument() that are really given on
the command line, i.e. those that it stumbles upon them during parse_args().
Regards,
Henry
--
http://mail.python.org/mailman/listinfo/python-list