Overriding methods per-object

Pavel Panchekha PavPanchekha at gmail.com
Sat Apr 18 03:22:49 CEST 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