Overloading "if object" unary operator

Fredrik Lundh fredrik at pythonware.com
Wed Nov 29 11:35:05 EST 2006


Sarcastic Zombie wrote:

> If I have a class
> 
> class A:
>     __init__(id)
>         self.id = id
> 
> is there any way to overload the 'if' unary usage to detect if a
> variable has a value?

http://effbot.org/pyref/__nonzero__

</F>




More information about the Python-list mailing list