How to get function name as a string in Python

2 Answers

0 votes
def mul(a, b):
   return a * b

s = mul.__name__

print(s)

  
  
  
'''
run:
  
mul
  
'''

 



answered Jun 6, 2021 by avibootz
0 votes
import time

s = time.__name__ 

print(s)

  
  
  
'''
run:
  
time
  
'''

 



answered Jun 6, 2021 by avibootz
...