example code: log = {} for t in range(5): for r in range(10): log.setdefault(r, '') += "test %d\n" % t pprint(log) instead, as the above is not possible, the following must be used: from operator import add ... ... ... add(log.setdefault(r, ''), "test %d\n" % t) ... ARGH! just checked - NOPE! add doesn't work. and there's no function "radd" or "__radd__" in the operator module. unless there are really good reasons, can i recommend allowing += on return result of function calls. i cannot honestly think of or believe that there is a reasonable justification for restricting the += operator. append() on the return result of setdefault works absolutely fine, which is GREAT because you have no idea how long i have been fed up of not being able to do this in one line: log = {} log.setdefault(99, []).append("test %d\n" % t) l.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4