please help shrink this each_with_index() implementation

Phlip phlip2005 at gmail.com
Wed Jan 6 00:30:09 CET 2010


> > Does it say how to convert a string containing either an integer
> > representation, or something alphabetic, into an integer, or a zero, in
> > like 1 method call? (No except: ?)
>
> If you mean something like this:
>
> >>> int('153')
>
> 153

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. So I will persist in my idiotic questions here!

> Then perhaps you should work through the tutorial to learn the basics.

They will tell me how to use except: (which is a good example why a
program should not use exceptions for its normal control flow if at
all possible).

Please, please, please save your newbie admonitions for those who
qualify!



More information about the Python-list mailing list