need design suggestions: local namespace problem

Brian Quinlan BrianQ at ActiveState.com
Tue Oct 2 18:54:45 EDT 2001


> "Brian Quinlan" <BrianQ at ActiveState.com> writes:
>
> > Why are you getting so fancy? Why can't you simply use:
> >
> > if running_under_qmail:
> > 	ERR_HARD = 100
> > else:
> > 	ERR_HARD = 75
>
> This would suffice if I were only referencing these variables a few
> times, but I need to do this many, many times throughout the
program.
>
> Doing an if/else every time I needed to refer to a variable would be
> too cumbersome.

You generate these assignments in a single module (you called it
Defaults.py) and import them in the modules that depend on the
constants, just as you desribed:

import Defaults
sys.exit(Defaults.ERR_HARD)

--
Brian Quinlan
BrianQ at ActiveState.com





More information about the Python-list mailing list