Answers for "python function find name"

1

python function find name

def functionA():
    print ("First function called!")

def functionB():
    print ("\nSecond function called!")

functionA()
print ("First function name: ", functionA.__name__)

functionB()
print ("Second function name: ", functionB.__name__)
# OUTPUT:
First function called!
First function name:  functionA
  
Second function called!
Second function name:  functionB
Posted by: Guest on September-09-2021
2

give a function a name python

def my_function():
    pass

class MyClass(object):
    def method(self):
        pass

print(my_function.__name__)         # gives "my_function"
print(MyClass.method.__name__)      # gives "method"

print(my_function.__qualname__)     # gives "my_function"
print(MyClass.method.__qualname__)  # gives "MyClass.method"
Posted by: Guest on April-10-2020
0

give a function a name python

for i in a:
    print i.__name__
Posted by: Guest on April-10-2020

Python Answers by Framework

Browse Popular Code Answers by Language