While we're talking about annoyances

GHUM haraldarminmassa at gmail.com
Sun Apr 29 05:06:05 EDT 2007


Steven,

> def index(sequence):
>     decorated = zip(sequence, xrange(len(sequence)))
>     decorated.sort()
>     return [idx for (value, idx) in decorated]

would'nt that be equivalent code?

def index(sequence):
    return [c for _,c  in sorted((b,a) for a, b in
enumerate(sequence))]

tested, gave same results. But worsens your doc2code ratio :)

Harald Armin Massa
--




More information about the Python-list mailing list