From: Raymond Hettinger > [Bob Ippolito] >> d.setdefault(k, factory=list).append(v) ? > > That is somewhat nice and backwards compatible too. -1 How is it more expressive than d.setdefault(k, []).append(v)? As far as I can see, it's longer and contains an extra obscure(ish) term (factory). And I agree with the other posters that other defaults are often useful, and further complicating the dictionary interface isn't particularly helpful. If conciseness is important, def addlist(d, k, v): d.setdefault(k, []).append(v) Paul.
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