getopt and options with multiple arguments

PoD pod at
Mon Dec 19 11:59:45 CET 2005

On Mon, 19 Dec 2005 02:29:41 -0800, pinkfloydhomer at wrote:

> I want to be able to do something like:
> * -o outputfile
> and then have the shell expand the * as usual, perhaps to hundreds of
> filenames. But as far as I can see, getopt can only get one argument
> with each option. In the above case, there isn't even an option string
> before the *, but even if there was, I don't know how to get getopt to
> give me all the expanded filenames in an option.
> Help! :)
> /David

The convention is to put options first and then any other stuff such as
filenames:- -o outputfile *

In this case getopt will return the options as one list and the rest as
another list.

More information about the Python-list mailing list