[Python-Dev] Those import related syntax errors again...
Fredrik Lundh
fredrik@pythonware.com
Thu, 22 Feb 2001 22:40:09 +0100
Thomas wrote:
> While on the subject: will all of 'from module import *' be deprecated, even
> at module level ?
hopefully not -- that would break tons of code, instead of
just some...
> How should code like Mailman's mm_cfg.py/Defaults.py construct be
> rewritten to provide similar functionality ? Much as I dislike 'from module
> import *', it really does have its uses.
how about:
#
# mm_config.py
class config:
# defaults goes here
spam = "spam"
egg = "egg"
# load user overrides
import mm_cfg
config.update(vars(mm_cfg))
#
# some_module.py
from mm_config import config
print "breakfast:", config.spam, config.egg
Cheers /F