« * K @trey.io

Trey Hunner @trey.io

2026-11-21 21:01 UTC

Python Tip #325 (of 365): Avoid returning defaultdict objects. 🧵 A defaultdict is handy while building a dictionary: by_color = defaultdict(list) for item in items: by_color[item.color].append(itemā€.name) But once you're done, it'll keep auto-creating missing keys. #Python #DailyPythonTip

Link: Setting default dictionary values in Python (pym.dev/default-dictionary-values/)

4 likes, 0 reposts, 2 replies

4 More from @trey.ioBackBluesky home
☆ Save to home · 0 Home · Find · Games · Chat · AI · Setup