getopt: where's da dicts?????

Markus Stenberg mstenber at cc.Helsinki.FI
Tue Oct 19 06:50:15 EDT 1999


"Fredrik Lundh" <fredrik at pythonware.com> writes:
> Les Schaffer <godzilla at netmeg.net> wrote:
> > just started using the getopt module. i was surprised to see it
> > returns the options in list format rather than perl's (better)
> > dictionary format.
> maybe that's because the order of the options may some-
> times be important, and python dictionaries are unordered.
>
> how does Perl handle that?

It does not. Nor should Python, for that matter. GNU tools' approach these
days is to make options order-neutral, barring cases where it'd hurt
backwards compatibility/functionality. 

Ever wondered why 'rsh host -l login' and 'rsh -l login host' _both_ work
on boxes with GNU-ish stuff, and just _one_ of them works on most modern
UNIXes? :P I've zapped rsh family of aliases from my system [moved to total
ssh use], but I recall the different syntaxes applied on HP<>Digital UNIX
for instance.

> (or maybe it's just the C heritage that shows through.
> guess you're expected to loop over the options, just
> as in C, and in that case, getopt.py has already made
> the opt = opt.items() for you...)

Looks like C heritage to me. IMNSHO order-oriented parsing of options is
Pure Evil(tm) and I consider Perl (for once) to do the Right Thing.

> </F>

-Markus

-- 
	    Markus Stenberg
Finger fingon at mpoli.fi for my PGP public key




More information about the Python-list mailing list