On Sat, Jun 15, 2013 at 11:15 PM, Jim Mooney <cybervigila...@gmail.com> wrote: > > ## Comparing different types for equality always fails: > > if '5' != 5: > print('oops')
It depends on the __eq__ and __ne__ methods defined by the types. int and str have their own implementations of "rich comparisons". But that's a subject for another thread and another time, when you've gotten deeper into implementing your own classes. > Finally, 1 and 0 are oh-so-special standins for True and False, > that should have been strangled in the cradle. As I already said, you can't return an int from __bool__ in 3.x. In 2.x, __nonzero__ can return 0 for False and a "non-zero" int for True -- but only an int (not long, float, etc). _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor