On Apr 17, 8:22 pm, Pavel Panchekha <pavpanche...@gmail.com> wrote: > 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?
The docs don't say you can do that: Special method names A class can implement certain operations that are invoked by special syntax (such as arithmetic operations or subscripting and slicing) by defining methods with special names. Should you be able to? -- http://mail.python.org/mailman/listinfo/python-list