steve+comp.lang.python at pearwood.info
Mon Feb 4 15:46:18 CET 2013
Peter Otten wrote:
> Saul Spatz wrote:
>> Now I have another question. If dunder methods are looked up only in the
>> class, not the instance, why did defining __nonzero__ the way I did work?
>> Shouldn't I have had to define it with a def? Is __nonzero__ a special
> Unfortunately the situation is a bit more complex. Classic classes (like
> Tkinter.Frame) behave differently from newstyle classes (subclasses of
> So Steven is wrong here.
Peter is correct -- I've been using Python 3 too much, and completely forgot
about old-style classic classes, which only exist in Python 2.
Sorry for any confusion.
Nevertheless, everything I said about dunder methods applies to "new style"
classes in Python 2, and all classes in Python 3.
More information about the Python-list