Can a function access its own name?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bobueland@yahoo.com

    #1

    Can a function access its own name?

    Look at the code below:

    # mystringfunctio ns.py

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

    cap ("hello")


    Running the code above gives the following output
    [color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]
    hello
    the name of this function is ???[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    I would like the output to be
    [color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]
    hello
    the name of this function is cap[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    Is that possible ?

Working...