getopt issues

David Bear iddwb at asu.edu
Wed Aug 27 22:25:21 CEST 2003


On Tue, 26 Aug 2003, Steven Taschuk wrote:
> > >>> args
> > '-Middwb at mainex1.asu.edu -AKHAAM at prlinux+898 [...]
>   [...]
> > >>> a, b = getopt.getopt(args, 'APQn')
> 
> getopt wants its arguments as a list of strings (like sys.argv),
> not one big string.  Here, for example,

many thanks.  I didn't think the 'list' of args that getopt wanted was a 
python list.

now that I've read a little more of the getopt documentation, it says that 
getopt stops processing when a 'nonoption' is encounted.  Is there a way 
to have it process the whole argument list, then only return the options 
specified in options, rather than have it through an exception and return 
nothing?

> >     >>> a, b = getopt.getopt(args.split(), 
'APQn') >     Traceback (most recent call last):
>       ...
>     getopt.GetoptError: option -M not recognized
> 
> as expected.
> 
> 





More information about the Python-list mailing list