[Email-SIG] PEP 8 module names for email 3.1?

Barry Warsaw barry at python.org
Thu Feb 9 03:52:28 CET 2006


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/email-sig/attachments/20060208/0ac4dcd1/attachment.pgp 


More information about the Email-SIG mailing list