Can a function access its own name?

bobueland at yahoo.com bobueland at yahoo.com
Sat Nov 19 12:52:20 EST 2005


Look at the code below:

    # mystringfunctions.py

    def cap(s):
        print s
        print "the name of this function is " + "???"

    cap ("hello")


Running the code above gives the following output

    >>>
    hello
    the name of this function is ???
    >>>

I would like the output to be

    >>>
    hello
    the name of this function is cap
    >>> 

Is that possible ?




More information about the Python-list mailing list