Hendrik van Rooyen
mail at microcorp.co.za
Thu Oct 18 08:36:24 CEST 2007
"Raymond Hettinger" <pyt...cn.com> wrote:
> More straight-forward version:
> def lastdetecter(iterable):
> t, lookahead = tee(iterable)
> 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...
More information about the Python-list