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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4