args command line...

Alex Martelli aleax at aleax.it
Sat Jul 20 08:06:33 EDT 2002


Shagshag wrote:

> hello,
> 
> i'm looking for a script able to handle/understand "common" command
> line options like :
> 
> ascript.py -option this_is_a_directory/*
> ascript.py -another_option file1 file2 file3 -another_option2
> this_is_another_dir
> 
> i think that should exist somewhere...
> 
> (i wish to learn as it should be written in a good pythoner's way but
> also gain time by re-using it)

Standard module getopt in the Python library does not meet your
examples because it follows a more restrictive standard: all
options come before all other arguments, and options with long
names start with -- (two dashes, not just one: one dash is
reserved for one-letter options, so e.g. -fop is equivalent to
-f -o -p, for options not taking arguments, and equivalent to
-f op, for an option taking an argument, as Unix users expect).

Optik, at http://optik.sourceforge.net/ , is much richer but
I think you will still have to tweak to get the option styles
you want, that don't appear to follow a recognizable standard.
Still, I'd suggest starting from there.


Alex




More information about the Python-list mailing list