3 ms·
Shouldn't the walrus operator solve this, or did they limit that to conditionals only for some reason? (my_dict[val] := my_dict.get(val, [])).append('foo')
by cma 6y ago
Shouldn't the walrus operator solve this, or did they limit that to conditionals only for some reason?
(my_dict[val] := my_dict.get(val, [])).append('foo')
- deleted 6y ago[deleted]
- BugsJustFindMe 6y agoHaha, probably. But counterpoints: 1) the walrus operator is stupid 2) the walrus operator is dangerous 3) `(my_dict[val] := my_dict.get(val, [])).append` is the opposite of simpler compared to `my_dict.setdefault(val, []).append` or (cleanestly) just `my_default_dict.append`