Is there something similar to list comprehension in dict?
pengyu.ut at gmail.com
Fri Nov 20 04:18:04 CET 2009
I'm wondering if there is something similar to list comprehension for
dict (please see the example code below).
d = dict(one=1, two=2)
def fun(d):#Is there a way similar to list comprehension to change the
argument d so that d is changed?
L = [1, 2]
def fun2(L):#this doesn't have any effect on the argument L
print L#[1, 2]
def fun3(L):# argument L is changed
L[:]=[1, 2, 3]
print L#[1, 2, 3]
More information about the Python-list