Overloading "if object" unary operator

Peter Otten __peter__ at web.de
Wed Nov 29 11:26:01 EST 2006


Sarcastic Zombie wrote:

> is there any way to overload the 'if' unary usage to detect if a
> variable has a value?

Define a __nonzero__() or __len__() method.

Peter





More information about the Python-list mailing list