On Wed, 2006-02-08 at 16:49 -0500, Fred L. Drake, Jr. wrote:
> 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")
> ...That's a great start Fred, thanks! I've now got a copy of the email package that supports both naming schemes. I've also got two copies of the test modules, one that tests the old names and one that tests the new names. The only change necessary in the old name tests was the __all__ test (which makes sense of course). So, rather than post patches or commit this to the Python trunk, I'm going to make a copy in the sandbox and check the changes in there. It would be great if people could check it out and let me know what you think. I'll send an email when that's done. -Barry
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Email-SIG mailing list [email protected] Your options: http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com
