Tagged articles
5 articles
Page 1 of 1
Code Mala Tang
Code Mala Tang
Mar 17, 2025 · Backend Development

How to Efficiently Map Dictionaries to Python Classes: From Namedtuple to Pydantic

Mapping external data such as MongoDB query results or API responses to Python class attributes can be done manually, but this article explores several automated approaches—including namedtuple, setattr, a custom ModelBase/Type mapper, and Pydantic—detailing implementation, error handling, and performance benchmarks to guide developers in choosing the optimal solution.

Data MappingNamedtuplePydantic
0 likes · 12 min read
How to Efficiently Map Dictionaries to Python Classes: From Namedtuple to Pydantic
Test Development Learning Exchange
Test Development Learning Exchange
Jun 26, 2024 · Fundamentals

Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples

This article introduces several useful classes from Python's collections module—including Counter, defaultdict, deque, namedtuple, ChainMap, UserList/UserDict/UserString, as well as heapq and an OrderedDict‑based LRU cache—explaining their purposes and providing ready‑to‑run code examples for each.

ChainMapCollectionsCounter
0 likes · 6 min read
Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples
MaGe Linux Operations
MaGe Linux Operations
Aug 7, 2020 · Fundamentals

4 Essential Python Tricks Every Beginner Should Master

Discover four practical Python techniques—list/dict/set comprehensions, namedtuple structures, enumerate/zip iteration, and f-string formatting—that boost code readability and efficiency, helping beginners transition from a simple “Hello World” to writing clean, maintainable scripts in their development journey.

BeginnerComprehensionsNamedtuple
0 likes · 3 min read
4 Essential Python Tricks Every Beginner Should Master