[Python-Dev] Decorators: vertical bar syntax

James Y Knight foom at fuhm.net
Mon Aug 9 18:38:35 CEST 2004


On Aug 8, 2004, at 9:31 PM, Bill Janssen wrote:

> Guido, could you expand on this principle a bit?  Just stated as it
> is, it sounds as pointless (to my untutored mind, at least :-), as the
> arguments about "@ is ugly, so it shouldn't be used".  After all,
> isn't "what the function does" an important external property of the
> function, and don't you have to peek inside the block to determine
> that?  For instance, how do you know whether a function is a generator
> unless you look for yield statements inside it?

A function being a generator only* affects the return value, so not 
knowing what functions are generator functions are really just a 
special case of not knowing the return value of any function. That can 
be solved with documentation, or a decorator.
e.g.
@returns(types.GeneratorType)

James

*: well not really, but to the external caller it's equivalent.



More information about the Python-Dev mailing list