[Python-Dev] method decorators (PEP 318) (original) (raw)

Greg Ewing greg at cosc.canterbury.ac.nz
Sun Mar 28 22:07:51 EST 2004


Skip Montanaro <skip at pobox.com>:

If not, you'll probably get people (newbies at least) trying to write stuff like this:

def foo(a): if a > 5: @attr: "bob" elif a > 0: @attr: "skip" else: @attr: "guido" The other forms (via a decorator, using explicit attribute assignments after the definition) make it explicit that these attribute assignments don't occur in the context of function execution.

Hmmm... What about

def foo(a): attributes: author = "Guido" deprecated = 1 body: b = sqrt(a) return 3 * b / 2

Would that provide sufficient clues that the attributes are not part of the body?

Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list