Coding style

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Jul 18 18:57:10 EDT 2006


Volker Grabsch a écrit :
> Bruno Desthuilliers <onurb at xiludom.gro> schrieb:
> 
>>PTY wrote:
>>
>>>I was asking whether it was better style to
>>>use len() or not.
>>
>>FWIW, it's also more generic (you could have an object supporting
>>pop() but not __len__()), less error-prone,
> 
> 
> While I agree with all other points, I don't think that it's less
> error-prone. 

There are less risk of a typo with "if a:" than with "if len(a) > 0".

> See my other posting where I worked out this a flaw
> of Python.

See my answer where I don't agree on this being a "flaw" - a "minor 
wart" at most !-)



More information about the Python-list mailing list