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?

STeVe
--
You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to