Question #937

In Python, functions can have attributes.

In Python, functions are objects. So they have attributes like other objects. For instance:


def foo():
    pass
setattr(foo, 'age', 23 )
setattr(foo, 'name', 'John Doe' )
print(getattr(foo, 'age'))
foo.gender ='male'
print(foo.gender)
print(foo.name)
print(foo.age)

(tutorialspoint.com/What-are-Python-function-attribute)


Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵