in place list modification necessary? What's a better idiom?

andrew cooke andrew at acooke.org
Tue Apr 7 09:01:04 EDT 2009


R. David Murray wrote:
>>   [...]
>>   try:
>>     dimensions.append(float(s))
>>   except:
>>     dimensions.append(float(quantization[s]))
>
> No, no, no; never use a bare except! :)

can you explain why?  i can't think of any reason why the code would be
better catching a specific exception.

as a general rule, maybe, but in this particular case i can't see a reason
- so i'm not sure if you're just pedantically following rules or if i've
missed something i should know.

andrew




More information about the Python-list mailing list