[CentralOH] Detect last iteration of iterator
Jon Miller
jonebird at gmail.com
Mon May 9 18:01:18 CEST 2011
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
...:
...:
0
1
2
3
4
5
6
7
8
9
Last call for alcohol 9
-- Jon Miller
On Mon, May 9, 2011 at 11:57 AM, Issac Kelly <issac.kelly at gmail.com> wrote:
> You could use an enumerator, but I think your way here is cleaner.
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
>
>
More information about the CentralOH
mailing list