Coding style

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Jul 18 20:55:43 EDT 2006


Carl Banks a écrit :
> Bruno Desthuilliers wrote:
> 
>>There are less risk of a typo with "if a:" than with "if len(a) > 0".
> 
> 
> So, it's more important to protect against typos than subtle bugs?
> 

People making smart points are really annoying... !-)

wrt/ to the "subtle bug" point, MHO is that a better solution could be 
to have iterators/generators implement __nonzero__ the same way numpy 
arrays do. It may not be a very strong argument, but I actually like the 
fact that empty sequences eval to false just like numeric zeros and None...



More information about the Python-list mailing list