How to print the function name as a string in Python from inside that function

python

Solution

This also works:

import sys

def applejuice(q):
    func_name = sys._getframe().f_code.co_name
    print func_name

Problem

``` def applejuice(q): print THE FUNCTION NAME! ``` It should result in "applejuice" as a string.

Original source

Related problems