optparse variable parsing?

CJ Kucera python at apocalyptech.com
Wed Mar 10 11:53:25 EST 2004


benjamin schollnick wrote:
> Sorry for butting in here....
> But 14 options?  Is there not a way you can simplify this instead?

:)  I was wondering if anyone was going to ask about this.  I used
an "adduser" script as an example, because I had written an adduser
script in Perl (with Getopt::Long, which supports the kind of -p
syntax I was suggesting in my post (and in fact that's how the util
functions)), and I felt that what I wanted to do was better explained
with that example as opposed to the util I'm actually doing in Python
this time.

If you're curious, it's a rather crazy little util I'm using to
obfuscate and confuse text in various terrifying ways, built
primarily for my own use on a private list which is currently
involved in a war of escalating post silliness.  I just keep on
thinking of new things to add to it, and many of them ("enable
flag x") also have very-closely-related probability variables
("for every line y, with flag x enabled there's a z% probability
of this behavior occuring (with a default value of z, which I
currently have to override with another flag instead of just having
an optional argument to -x)).  Hopefully some part of that rambling
makes sense.

All but one or two of these options can be used in any kind of
combination with each other, too, leading to further and trickier
obfuscations; it's all quite ridiculous as you can see.  But
regardless, splitting it into different programs doesn't make sense,
and while I could certainly code an INI file for the thing, I'm just
not going to 'cause I like having it all on one line.  :)

> But if the command line is running low on space, turn the idea 90
> degrees, and declare it imaginary....

Heh, indeed.  Were this a more "serious" project I'd probably be
trying harder to find a good compromise.

Thanks for the response!

-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