[Python-Dev] Call for defense of @decorators

James Y Knight foom at fuhm.net
Thu Aug 5 20:04:56 CEST 2004


One thing I thought of recently that would be IMO a nice feature to 
have is something like this:

 >>>
@public
def f(...):
  pass

@public
y = 5
<<<

which would essentially set __all__ = ['f', 'y'] for you. However, that 
isn't possible to do with the current function-modifying-only 
decorators. For this to be possible, the decorator would need to get as 
an argument the binding (perhaps in the form of the container and the 
name), as well as the object being assigned to that binding. (also the 
grammar would have to be updated but that's relatively easy I suspect)

I don't have an argument or proposal here, just putting this out to 
think about.

James

PS: I like decorators, and the pie-shape is really growing on me. :)



More information about the Python-Dev mailing list