Isn't there a better way?

John J. Lee jjlee at reportlab.com
Fri Jul 21 19:38:16 EDT 2006


Peter Otten <__peter__ at web.de> writes:
[...]
> Not sure if this is better, but you can use OptionParser to set attributes
> on arbitrary objects, including your Processor instance:
[...]

I'd guess it's not worth the mental overhead required when you
discover the next argument no longer fits this scheme.  Or the mess
when you start lying to yourself about what the interface of Processor
should be, just so you can implement it like this.

Still, better than just passing 'options' (from options, args =
parser.parse_args()) to all your functions / classes, which... well,
only makes sense if you get paid by the hour, and think that way, too
;-)


John



More information about the Python-list mailing list