How complex is complex?

Kottiyath n.kottiyath at gmail.com
Wed Mar 18 13:30:45 EDT 2009


When we say readability counts over complexity, how do we define what
level of complexity is ok?
For example:
Say I have dict a = {'a': 2, 'c': 4, 'b': 3}
I want to increment the values by 1 for all keys in the dictionary.
So, should we do:
>>> for key in a:
...   a[key] = a[key] + 1
or is it Ok to have code like:
dict(map(lambda key: (key, a[key] + 1), a))

How do we decide whether a level of complexity is Ok or not?



More information about the Python-list mailing list