📅 2012-May-03 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ function, name, python ⬩ 📚 Archive
The __name__
attribute of a function holds the function name. Even if the function is assigned to a new variable, its name remains the name with which it was originally defined. Lambda functions have the name <lambda>
def squareIt( x ):
return x * x
print( squareIt.__name__ ) # squareIt
= squareIt
foo print( foo.__name__ ) # squareIt
= lambda x: x * x
squareIt print( squareIt.__name__ ) # <lambda>
= squareIt
foo print( foo.__name__ ) # <lambda>
Tried with: Python 3.2