Simon Mullis: > h = { "1" : "a\r", "2" : "b\n" } > I have the option of an in-place method: > h.each_value { |v| val.strip! }
This in-place version may be the closer code for Python 2.x: d = {"1": "a\r", "2": "b\n"} d.update((k, v.strip()) for k, v in d.iteritems()) You may also want to use v.rstrip() there instead. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list