Any way for a function to refer to itself?

Lee, Rick rickylee at americasm01.nt.com
Thu Feb 22 14:32:50 EST 2001


I can't find any other way for a function or method to refer to itself
than something like the following:

def foo():
    myself = foo   # only if foo is global
    mydoc = myself.__doc__
    myname = myself.__name__

So it can be done this way, but:

- only if the function name can actually be accessed from the current
name space
- if the function name changes, that first line inside this function
also has to change

Seems to me there should be a more "Pythonic" way of doing this.  Is
there?




More information about the Python-list mailing list