Overriding methods per-object

Pavel Panchekha PavPanchekha at gmail.com
Fri Apr 17 21:22:49 EDT 2009


I've got an object which has a method, __nonzero__
The problem is, that method is attached to that object not that class

> a = GeneralTypeOfObject()
> a.__nonzero__ = lambda: False
> a.__nonzero__()
False

But:

> bool(a)
True

What to do?



More information about the Python-list mailing list