1def functionA():
2 print ("First function called!")
3
4def functionB():
5 print ("\nSecond function called!")
6
7functionA()
8print ("First function name: ", functionA.__name__)
9
10functionB()
11print ("Second function name: ", functionB.__name__)
12# OUTPUT:
13First function called!
14First function name: functionA
15
16Second function called!
17Second function name: functionB
1def my_function():
2 pass
3
4class MyClass(object):
5 def method(self):
6 pass
7
8print(my_function.__name__) # gives "my_function"
9print(MyClass.method.__name__) # gives "method"
10
11print(my_function.__qualname__) # gives "my_function"
12print(MyClass.method.__qualname__) # gives "MyClass.method"