Decorators

Mel Wilson mwilson at the-wire.com
Tue Aug 10 08:01:00 EDT 2004


In article <mailman.1431.1092121563.5135.python-list at python.org>,
Andrew Durdin <adurdin at gmail.com> wrote:
>On Mon, 09 Aug 2004 20:29:59 -0400, Colin J. Williams <cjw at sympatico.ca> wrote:
>>
>> There is also the question of whether 'decorator', a term which is used
>> in everyday langage as indicating adornment, is the best choice for a
>> transformation.
>
>def deco(f):
>    print f.__name__, "is now pretty!"
>    return f

def deco (f):
    print f.__name__, "is now pretty!"
    def t (*s,**k):
        print """\
I'm so pretty, oh so pretty!
I'm so pretty and witty and bright!
"""
    return t

>
>@deco
>def ugly_function():
>    pass


Throw in an f(*s,**k) there if you really feel you must.


        Regards.        Mel.


Portions copyright by Stephen Sondheim or somebody.



More information about the Python-list mailing list