try/except in a loop

Andrew Berg bahamutzero8825 at gmail.com
Wed May 2 16:07:15 EDT 2012


Why wouldn't a for loop work? If something works, you can break out,
otherwise continue.

working_obj = None
for obj in iterable:
	try:
		obj.do_something()
		working_obj = obj
		break
	except:
		continue

-- 
CPython 3.3.0a3 | Windows NT 6.1.7601.17790



More information about the Python-list mailing list