[Email-SIG] PEP 8 module names for email 3.1?
Fred L. Drake, Jr.
fdrake at acm.org
Wed Feb 8 22:49:43 CET 2006
On Wednesday 08 February 2006 14:47, Barry Warsaw wrote:
> So first the question is whether anyone else would like to see this.
+1
> If
> the answer to that is "yes", then the next question is, what's the best
> way to accomplish this while retaining the existing API for backward
> compatibility?
This is a clear case for lazy imports; perhaps something like this in
email/__init__.py:
import sys
class LazyImporter(object):
def __init__(self, module_name):
self.__module_name = module_name
def __getattr__(self, name):
__import__(self.__module_name)
mod = sys.modules[self.__module_name]
self.__dict__.update(mod.__dict__)
return getattr(mod, name)
sys.modules["email.MIMEText"] = LazyImporter("email.mime.text")
...
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
More information about the Email-SIG
mailing list