On 6/15/10 9:16 PM, John Nagle wrote: > Cute, but it doesn't work in general. Faking a module as a > class fails when you simply call > > x() > > within the module.
Huh? Explain how it doesn't work? I've done it at least twice (shamefully do I admit this) and it works fine. Real life code. > Any more ideas? There aren't any; modules do not follow the class object protocol. They are simple types with a __dict__ (which you can't change, either, so no replacing it with a dict that implements __setattr__). Replacing the module with a class in sys.modules is really the only way to fake the behavior. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/
signature.asc
Description: OpenPGP digital signature
-- http://mail.python.org/mailman/listinfo/python-list