1

For logging, I would like each function to log its own name at the start and end of the function. What is the simplest way to do this? The most straightforward way would be

def my_function():
    print("Enter my_function")
    # ...
    print("Leave my_function")

If I change the name of the function, I have to update these print messages as well.

  • Is there something like __name__ within a function for its own name?
Fabian
  • 4,001
  • 4
  • 28
  • 59

0 Answers0