[Email-SIG] PEP 8 module names for email 3.1? (original) (raw)
Fred L. Drake, Jr. fdrake at acm.org
Wed Feb 8 22:49:43 CET 2006
- Previous message: [Email-SIG] PEP 8 module names for email 3.1?
- Next message: [Email-SIG] PEP 8 module names for email 3.1?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [Email-SIG] PEP 8 module names for email 3.1?
- Next message: [Email-SIG] PEP 8 module names for email 3.1?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]