python (12.9k questions)
javascript (9.2k questions)
reactjs (4.7k questions)
java (4.2k questions)
java (4.2k questions)
c# (3.5k questions)
c# (3.5k questions)
html (3.3k questions)
How to sort default dict with list values in python
I have a defaultdict with list as
defaultdict(<class 'list'>, {'SOL200122': ['125', '135', '145', '170', '120', '130', '140', '150', '160']}
I want it to be sorted like
defaultdict(<class 'l...
Madan
Votes: 0
Answers: 2
A dataclass as a key to a defaultdict: KeyError
Please explain and maybe help how to fix defaultdict with a frozen dataclass key.
Example:
"""Reproduce KeyError: defaultdict with dataclass keys"""
import collections
i...
Tometzky
Votes: 0
Answers: 2
Is there a better way to merge two dicts of sets?
I am using this code to merge one dict into another - if a key exists, it should merge the values from both dicts:
source_dict = defaultdict(set)
target_dict = defaultdict(set)
def merge_dict(source_...

marlon
Votes: 0
Answers: 2
Default dict with a non-trivial default
I want to create a "default dict" that performs a non-trivial operation on the missing key (like a DB lookup, for example). I've seen some old answers on here, like Using the key in collect...

zenzic
Votes: 0
Answers: 1