map-like function on dict values?

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Wed Feb 27 20:04:50 EST 2002


Is there a way to do this

for k, v in dict.items():
    dict[k] = f(v)

without involving a Python for loop?  I'd imagine that a function
implemented in C could speed things up quite a bit.  Something like
either of the following

mapvalue(f, dict)
dict.mapvalue(f)

Huaiyu



More information about the Python-list mailing list