Can I use a python object in a desired boolean context?
By default any object is True
in boolean context.
>>> class Person():
... pass
...
>>> a=Person()
>>> bool(a)
True
Like bool(0)
returns False
and bool(1)
returns True
.Can i have any way to define an object to have it's boolean value either True
or False
.
Correct me if i'm wrong anywhere,thanks.