Extracting an undefined number of items from a list

Patrick Maupin pmaupin at gmail.com
Mon Apr 12 22:58:01 EDT 2010

On Apr 12, 9:26 pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:

> # The obfuscated, fragile way
> map( itemgetter(0), sorted(
>      zip(db, range(1, len(db)+1)), key=lambda t: t[1] if t[1] in i else -1
>      )[-len(i):] )

I have to hand it to you that this might, in fact, be "the"
obfuscated, fragile way, but I gotta tell you that I'm certain there
exist other ways that are considerably less obfuscated and
considerably less fragile that I, personally would still consider to
be obfuscated and fragile...

The only thing you get points off for is the lack of a multiply or
divide by 10.  The original data set is just crying out for such a
thing, and, while it might not do all that much for the obfuscation,
it would certainly help with the fragility. ;-)


More information about the Python-list mailing list