Autoloading? (Making Queue.Queue easier to use)
May be allow modules to define __getattr__ ? def __getattr__(thing): try: return __some_standart_way__(thing) except AttributeError: if thing=="Queue": import sys from Queue import Queue setattr(sys.modules[__name__],"Queue",Queue) return Queue raise
Sokolov Yura wrote:
May be allow modules to define __getattr__ ?
I think I like the descriptor idea better. Besides being more in keeping with modern practice, it would allow for things like from autoloading import autoload Foo = autoload('foomodule', 'Foo') Blarg = autoload('blargmodule', 'Blarg') where autoload is defined as a suitable descriptor subclass. I guess we could do with a PEP on this... Greg
Sokolov Yura wrote:
May be allow modules to define __getattr__ ?
def __getattr__(thing): try: return __some_standart_way__(thing) except AttributeError: if thing=="Queue": import sys from Queue import Queue setattr(sys.modules[__name__],"Queue",Queue) return Queue raise
I proposed something like this in the RFE tracker a while ago, but no one commented on it. Reinhold -- Mail address is perfectly valid!
participants (3)
-
Greg Ewing -
Reinhold Birkenfeld -
Sokolov Yura