optparse variable parsing?
CJ Kucera
python at apocalyptech.com
Mon Mar 8 18:26:39 EST 2004
Hello, list!
I'm wondering if it's possible to have an option with optparse function
as either a true/false option, or optionally use a supplied value when
it's provided.
For example, let's say that I'm writing a util to add a user to some
system. By default, the program would assign a random password:
> $ adduser.py
> Assigned password: <blah>
If the user specifies "-p", the program would prompt for a password
instead:
> $ adduser.py -p
> Pass:
> Confirm:
And then it'd be great to be able to pass in a hashed value and have
the program use that instead:
> $ adduser.py -p\$1\$KgM/m2Ys\$.o0sbvwHddeKMCKJdfcMJ0
Is something like that possible with optparse?
Thanks!
-CJ
--
WOW: Kakistocracy | "The ships hung in the sky in much the same
apocalyptech.com/wow | way that bricks don't." - Douglas Adams,
python at apocalyptech.com | _The Hitchhiker's Guide To The Galaxy_
More information about the Python-list
mailing list