[CentralOH] Detect last iteration of iterator

Mark Erbaugh mark at microenh.com
Mon May 9 20:08:23 CEST 2011


On May 9, 2011, at 12:01 PM, Jon Miller wrote:

> Yeah, I like your first method better too, but a 'finally' clause
> popped into my head, so I thought I'd share it...
> In [1]: try:
>   ...:     for i in range(10):
>   ...:         print i
>   ...: except (Exception, e):
>   ...:     pass
>   ...: finally:
>   ...:     print 'Last call for alcohol %d' % i
>   ...:


How is this any different than just:

for i in range(10):
	print i

print 'Last call..."


Mark


More information about the CentralOH mailing list