List mapping?

Nick Trout nick at spam_me_notvideosystem.co.uk
Thu Apr 13 11:20:24 EDT 2000


> Try this:
> mylist = ['/a','1','/b','2','/c','3']
> map(lambda x: reduce(lambda a, b: (a,b), mylist[x:x+2]), range(0,
> len(mylist), 2))

Very good! I wasnt familiar with the reduce function. I would certainly not have
come up with something of this complexity.

This begs the question: Is there an archive of code snippets for Python? These
could form an excellent tutorial. Quite a few messages arrive on this newsgroup
asking for good starting points for Python (and thats just the people who come
here and ask).

N





More information about the Python-list mailing list