Question about a single underscore.
Paul Rubin
http
Thu Feb 1 12:16:29 EST 2007
"Steven W. Orr" <steveo at syslang.net> writes:
> ------------------><8------------------- const.py-------------
> ...
> sys.modules[__name__]=_const()
__name__ is 'const' since this file is const.py. So you've
juset set the const module to actually be a const instance.
> 1. Why do I not have to say
> _const.pi = 3.14159
const.pi refers to item 'pi' in the const module, which you've
set in sys.modules above.
> 2. Can I make this behave in such a way that I can create my constants
> with a classname that is different for different uses? e.g.,
> irrational_const.pi = 3.14159
Yes, irrational_const = _const()
More information about the Python-list
mailing list