Consider the following code :

# --------------------------------------
def bool_equivalent(x):
    return True if x else False


# testing ...

def foo(x):
    return 10*x

class C:
    pass

for x in [42, ("my","baby"), "baobab", max, foo, C] + [None, 0, "", [], {},()]:
    print bool(x)==bool_equivalent(x)
# --------------------------------------


Is the bool_equivalent() function really equivalent to the bool() built-in function ?



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to