Oltmans wrote:
On May 9, 1:53 am, superpollo <ute...@esempio.net> wrote:
add = lambda a,b: a+b
for i in reduce(add,a):
print i
This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.
shorter <> nicer IMO.
Those alternatives are interesting from a tech point of view, but
nothing can beat the purity of a vintage 'for' loop with *meaningful names*.
salads = [['apple', 'banana'], ['apple', 'lemon', 'kiwi']]
ingredients = []
for salad in salads:
for fruit in salad:
ingredients.append(fruit)
print 'Remember to buy %s' % ingredients
Lame & effective (1st adjective is irrelevant outside a geek contest)
JM
--
http://mail.python.org/mailman/listinfo/python-list