
On Wed, Mar 17, 2010 at 11:49 PM, nbv4 <nbvfour@gmail.com> wrote:
Decorators are great, they make this:
def some_func(*args, **kwargs): return "sup" some_func = decorator(some_func)
into this:
@decorator def some_func(*args, **kwargs): return "sup"
which makes the code look more structured. The line at the bottom looks more like it 'belongs' to the function when it's at the top of the def block, as opposed to the bottom.
But when it comes to function properties, it'd be nice if that same pattern was availiable:
def some_func(*args, **kwargs): return "sup" some_func.printable = True
becomes:
@printable=True def some_func(*args, **kwargs): return "sup"
Any thoughts?
Are function attributes used *that* much? Cheers, Chris -- http://blog.rebertia.com