On 8/19/2010 7:51 AM Pete said...
Hi,
I've been reading up on list comprehensions lately, all userful and powerful
stuff - trying to wrap my brain around it :)
As the examples all seem to relate to lists, I was wondering if there is an
elegant similar way to apply a function to all keys in a dictionary?
(without looping over it, of course)
Just fyi, as it sounds you may not understand. List Comprehensions loop
over the list. There's no other magic going on that avoids that.
result = [ ii for ii in lst if cond ]
is just shorthand for
result = []
for ii in lst:
if cond:
result.append(ii)
Emile
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor