args command line...

James Kew james.kew at btinternet.com
Sat Jul 20 13:59:21 EDT 2002


"Jim Jinkins" <j-jinkins at usa.net> wrote in message
news:3D399A3D.1060002 at usa.net...
> Shagshag wrote:
>
> >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...
>
> See module getopt in the standard library.

...subject to the limitations pointed out by other posters: getopt stops
processing options after the first non-option argument, and it requires --
before long option names.

The original poster might also find the standard library's glob module
useful for expanding that "this_is_a_directory/*" argument into a list of
files. I also quite like os.path.expandvars()...

--
James Kew
james.kew at btinternet.com






More information about the Python-list mailing list