retry in try:...except:

Dan Parisien dan at eevolved.com
Sun Feb 11 17:09:20 EST 2001


Fredrik Lundh wrote:

> Dan Parisien wrote:

> while 1:
>     try:
>         something()
>     except:
>         fix_possible_error()
>     else:
>         break

that's what I ended up doing as a work-around. much less readable however

> for item in list:
>     do_something(item)
No. I want the indexes instead of using range(len(list)) over and over

> (or "def indexes(list): return range(len(list))")
I know ;)
but why code it over and over in each script you need it?

I am a big fan of code reuse. Every time I write something twice, I have a 
bad gut feeling because I know I'm doing it uselessly :(

Dan



More information about the Python-list mailing list