In python it is valid to make a construction like:
def a():
return 0
if a:
print "Function object was considered True"
else:
print "Function object was considered False"
I wish to ask what is the logic that a function pointer is evaluated to True.
Why was this kind of construction inserted in the language?
A lot of things evaluate to
Truein Python. From the documentation on Boolean operators:Functions in Python, like so many things, are objects, and not empty. Thus, in a boolean context, they evaluate to True.