[Question] Functional style with lists

Alex alex at somewhere.round.here
Tue May 4 19:51:00 EDT 1999


You might want to look into the operator module.  Instead of 

>>> map(lamda x,y:x+y,map(L.getitem,(1,)*len(L)))

the commands 

>>> L = [ ("John",40), ("Monthy",35)]
>>> import operator
>>> reduce (operator.add, \
            map (operator.getitem, L, len(L) * (1, )), \
            0)
75

perhaps do what you expected.  Gets messy very fast, though...

Alex.




More information about the Python-list mailing list