[Python-Dev] method decorators (PEP 318) (original) (raw)
Alex Martelli aleaxit at yahoo.com
Sat Mar 27 03:09:21 EST 2004
- Previous message: [Python-Dev] method decorators (PEP 318)
- Next message: [Python-Dev] method decorators (PEP 318)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2004 Mar 27, at 06:27, Barry Warsaw wrote: ...
attributes, but decorators can also do the trick in a nasty way:
def foobar [ lambda f: f.author = 'Guido van Rossum', lambda f: f.deprecated = True, classmethod] (self, arg): # Now what?
Not necessarily all that nasty:
def foobar [ with_attributes( author="Guido van Rossum", deprecated=True), classmethod] (cls, args): pass
with a built-in 'with_attributes' equivalent to:
def with_attributes(f, **kwds): for k, v in kwds.iteritems(): setattr(f, k, v) return f
Alex
- Previous message: [Python-Dev] method decorators (PEP 318)
- Next message: [Python-Dev] method decorators (PEP 318)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]