"Raymond Hettinger" <pyt...cn.com> wrote: > More straight-forward version: > > def lastdetecter(iterable): > t, lookahead = tee(iterable) > lookahead.next() > return izip(chain(imap(itemgetter(0), izip(repeat(False), > lookahead)), repeat(True)), t)
If this is what you call straightforward - heaven forfend that I ever clap my orbs on something you call convoluted! :-) Faced with this problem, I would probably have used enumerate with a look ahead and the IndexError would have told me I am at the end... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list