code critique requested - just 60 lines
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Thu Oct 2 11:56:46 EDT 2008
Terrence Brannon, I suggest you to shorten a lot some of those very
long lines.
> # http://code.activestate.com/recipes/278259/
> def sumDict(d):
> return reduce(lambda x,y:x+y, d.values())
Not all recipes are good, and that looks bad in various ways. Try
this:
def sumDictValues(d):
return sum(d.itervalues())
But probably it's better to inline that operation.
Bye,
bearophile
More information about the Python-list
mailing list