please help shrink this each_with_index() implementation
python at mrabarnett.plus.com
Wed Jan 6 03:59:50 CET 2010
Antoine Pitrou wrote:
>> The point: int('') or int('something') both throw an error. In general,
>> this is hand-holding, but in specific I don't think the "rich and
>> structured" documentation will cover how to beat a 0 out of it in less
>> than 3 lines.
> Because it's a bad idea to do so and Python doesn't encourage such sloppy
> behaviour. If you like it, though, you might prefer PHP.
> By the way: error reporting is definitely *not* hand-holding. It is
> simply not good to let errors pass silently by default. Again, if you
> think the contrary, PHP is your friend ;-)
Someone wrote about a port of a Perl script to Python. The script would
parse the output from a program it would call, but the Python script
sometimes raised a ValueError when it tried to convert a certain field
to a number. It turned out that sometimes the field would contain
"ERROR" instead of a number. The Perl script had been silently
'converting' any such "ERROR" to 0!
More information about the Python-list