command line arguments (newbie...)

P at draigBrady.com P at draigBrady.com
Tue Nov 25 11:17:12 EST 2003


Matteo Risoldi wrote:
> Hello,
> 
> Still, I would like to be able to use the "-t" argument with OR without a
> parameter, i.e. if I specify something after -t, it should go into
> "separator", but if I don't specify anything, "separator" should keep its
> default value (which is set elsewhere).
> Now, the problem is that with getopt.getopt, if I put "t:"in the option
> list, then I HAVE to put something after it; if I put only a "-t" on the
> command line, I get a getopt.GetoptError exception. I have tried putting
> both "t:" and "t" in the option list, but this won't work. At first I had
> thought about testing "if arg" and only then assigning a value to separator,
> but as I said the "-t" argument without parameters would not even be
> accepted.
> 
> Any suggestion on how to achieve this?

man 3 getopt suggests t:: should work.
If it doesn't then it's another broken python reimplementation of a
standard library: 
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3FA78E34.4050502%40draigBrady.com

Pádraig.





More information about the Python-list mailing list