On Oct 14, 5:58 am, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 14, 8:00 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > > def signal_last(lst): > > last2 = None > > it = iter(lst) > > try: > > last = it.next() > > except StopIteration: > > last = None > > for last2 in it: > > yield False, last > > last = last2 > > yield True, last > > This yields a value when the iterator is empty, which Diez's solution > didn't. Logically, there is no 'last' element in an empty sequence, > and it's obscure to add one. Peter Otten's improvement to Diez's code > looks the best to me: simple, readable and correct. >
Of course! For some reason I thought I was improving Peter Otten's version, but when I modified my submission to behave as you stated, I ended right back with what Peter had submitted. Agreed - nice and neat! -- Paul -- http://mail.python.org/mailman/listinfo/python-list