Bootstrap FreeKB - Python (Scripting) - Return function name
Python (Scripting) - Return function name

Updated:   |  Python (Scripting) articles

Here is an example of how you can capture and return function name.

#!/usr/bin/python3
import inspect
def my_function():
  function_name = inspect.currentframe().f_code.co_name
  print("function name = {function_name}")

my_function()

 

Which should return something like this.

function name = my_function

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 695496 in the box below so that we can be sure you are a human.