Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Sergey Kishchenko
In Python empty container equals False in 'if' statements: # prints "It's ok" if not []: print "It's ok" Let's create a simple Foo class: class Foo: pass Now I can use Foo objects in 'if' statements: #prints "Ouch!" f=Foo() if f: print "Ouch!" So, default __nonzero__ impl is to re

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Sergey Kishchenko
On 8 янв, 22:03, "Chris Rebert" wrote: > On Thu, Jan 8, 2009 at 5:53 AM, Sergey Kishchenko wrote: > > In Python empty container equals False in 'if' statements: > > > # prints "It's ok" > > if not []: > >    print "It