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>
_______________________________________________
Email-SIG mailing list
[email protected]
Your options: 
http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com

Reply via email to