What's the use of changing func_name?

could ildg could.net at gmail.com
Thu May 19 01:47:23 EDT 2005


def a(func):
    def _inner(*args, **kwds):
        print "decorating..."
        return func(*args, **kwds)
    _inner.func_name = func.func_name -->when I delete this line, the
rusult is the same. why?
    return _inner

@a
def g(*args):
    for x in args:
        print x
    print "this is in function g"

g(1,2,3,4,5)

func_name is writable in python 2.4. I wonder what's the use of
writing it. Consider the code above, to change the func_name or not
will get the completely same result. The result is as
below:

decorating...
1
2
3
4
5
this is in function g

Please tell me how does this happen, thank you~



More information about the Python-list mailing list