[Chandler-dev] Harmful usage of len()

Grant Baillie grant at osafoundation.org
Wed Jun 6 10:21:13 PDT 2007


On 6 Jun, 2007, at 10:06, D John Anderson wrote:

> Is it ever the case that __nonzero__ would return a value  
> inconstant from using __len__ so using it instead of len would  
> cause a bug?

I think you meant "inconsistent". But anyway, if one codes  
__nonzero__ stupidly, sure. (BTW, if your class doesn't have  
__nonzero__, but does have __len__, boolean "typecasts" of your  
objects will evaluate __len__).

--Grant




More information about the chandler-dev mailing list