Passing options between modules

Larry Bates lbates at swamisoft.com
Fri May 21 19:05:13 EDT 2004


One suggestion would be:

Create small class, something like:

class globaloptions:
    pass

Then assign your options to attributes of this
class:

globaloptions.option1=value
globaloptions.option2=value
...
globaloptions.optionn=value

Then pass globaloptions class to everyone else:

a=Aclass(opt1, opt2, globaloptions)
bFunction(globaloptions)
...

Larry Bates
Syscon, Inc.

"Chris" <iamlevis3 at hotmail.com> wrote in message
news:939f49f8.0405210907.4f12a613 at posting.google.com...
> I'm trying to come up with a not-so-ugly manner of passing many
> command-line options between modules.
>
> I have a Steering.py file, which contains my main() and handles the
> getopts getting of several command-line options.  Since having 5-6
> additional parameters for every class instantiation or function call
> is obviously an ugly way to handle this, what would you folks
> recommend as a superior option?  Maybe passing a dict of options to
> each object/function?
>
> Help on this topic is greatly appreciated.
>
> Go Sox,
> -cjl





More information about the Python-list mailing list