[Python-Dev] Autoloading? (Making Queue.Queue easier to use)

Steven Bethard steven.bethard at gmail.com
Mon Oct 17 06:21:31 CEST 2005

Nick Coghlan wrote:
> Having module attribute access obey the descriptor protocol (__get__, __set__,
> __delete__) sounds like a pretty good option to me.
> It would even be pretty backwards compatible, as I'd be hardpressed to think
> why anyone would have a descriptor *instance* as a top-level object in a
> module (descriptor definition, yes, but not an instance).

Aren't all functions descriptors?

py> def baz():
...     print "Evaluating baz!"
...     return "Module attribute"
py> baz()
Evaluating baz!
'Module attribute'
py> baz.__get__(__import__(__name__), None)
<bound method ?.baz of <module '__main__' (built-in)>>
py> baz.__get__(__import__(__name__), None)()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: baz() takes no arguments (1 given)

How would your proposal change the invocation of module-level functions?

You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy

More information about the Python-Dev mailing list