Tagged articles
dataclasses
17 articles · Page 1 of 1
The article presents eight practical Python techniques—from using python -m to avoid import errors, leveraging rich for better debugging output, pathlib for path handling, dataclasses to reduce boilerplate, enumerate, proper __main__ guard, perf_counter for benchmarking, and watchdog for hot-reloading—each with code examples, showing how they cut down repetitive tasks and improve productivity.
DebuggingPythonWatchdog
0 likes · 13 min read

This article presents eight practical Python techniques—from using python -m to avoid import errors, to pathlib for path handling, dataclasses for boilerplate reduction, rich for pretty debugging, enumerate, proper __main__ guards, perf_counter for accurate timing, and watchdog for hot‑reloading—each designed to eliminate daily friction and boost development efficiency.
PythonWatchdogdataclasses
0 likes · 14 min read

This article showcases six powerful yet often overlooked Python standard‑library features—pathlib, contextlib, __slots__, functools.lru_cache, generator pipelines, and dataclasses—demonstrating how they simplify code, boost performance, reduce memory usage, and make scripts more maintainable.
LRU cachePython__slots__
0 likes · 11 min read

This article explains what Python dataclasses are, how they simplify data‑oriented class definitions, and demonstrates advanced features like custom field behavior, the __post_init__ method, and immutable (frozen) classes with clear code examples.
Code SimplificationImmutablePython
0 likes · 4 min read

The article explains that using a custom __init__ method to create data structures couples object construction with side‑effects, leading to fragile code, and demonstrates how refactoring with @dataclass, @classmethod factories and typing.NewType yields cleaner, safer, and more testable Python classes.
NewTypeObject Constructionclassmethod
0 likes · 13 min read

The article explains why defining custom __init__ methods for simple data structures is a bad practice in Python and proposes a modern solution using dataclasses, classmethod factories, and typing.NewType to create clear, testable, and type‑safe class interfaces.
Pythonbest-practicesclassmethod
0 likes · 13 min read

This article explains why returning None for missing values can cause unexpected errors in Python code and presents five practical alternatives—including default values, raising exceptions, special objects, type‑hinted optional returns, and dataclasses—to handle absent data safely and cleanly.
Default ValuesPythondataclasses
0 likes · 4 min read

This guide explores Python class fundamentals, covering inheritance versus composition, the use of super(), distinctions among instance, class, and static methods, dataclasses, the __dict__ attribute, name mangling, @property, dynamic class creation with type(), and __slots__ for attribute control.
ClassesCompositionInheritance
0 likes · 9 min read

This article introduces five Python libraries—attrs, bidict, Box, dataclasses, and DottedDict—explaining their installation, core features, and practical code examples for simplifying data class creation, bidirectional mapping, nested data access, and configuration management.
Boxattrsbidict
0 likes · 10 min read

This article explains how Python's dataclasses module, combined with the typing library, can automatically generate boilerplate methods, provide rich type annotations, support optional and union types, enable dictionary serialization, perform runtime checks, and be extended with field metadata for robust, maintainable code.
Code ExamplesPythondataclasses
0 likes · 6 min read

This article introduces nine powerful Python standard library modules that enhance code efficiency and readability, covering context management, iterators, concurrency, file operations, functional programming, AST parsing, type hints, data classes, and async programming.
ASTPythonasyncio
0 likes · 4 min read

This article reviews recent Python standard‑library enhancements, showing how pathlib replaces os.path, secrets supersedes os.urandom, zoneinfo replaces pytz, dataclasses improve on namedtuple, proper logging outperforms print, f‑strings beat format, tomllib replaces tomli, and setuptools supersedes distutils, with code examples for each.
LoggingPythondataclasses
0 likes · 13 min read

This article reviews the most useful additions to the Python standard library—Pathlib, Secrets, Zoneinfo, Dataclasses, proper logging, f‑strings, Tomllib and Setuptools—explaining why they replace older modules, showing concise code examples, and offering guidance on adopting them in everyday projects.
LoggingPythondataclasses
0 likes · 14 min read

This article reviews several modern Python standard‑library modules—Pathlib, Secrets, ZoneInfo, Dataclasses, proper logging, f‑strings, Tomllib, and Setuptools—explaining why they replace older alternatives and providing concise code examples to help developers adopt best practices and keep their projects up‑to‑date.
Loggingdataclassespathlib
0 likes · 13 min read

This article introduces the most useful additions and modern replacements in recent Python releases—including pathlib, the secrets module, zoneinfo, dataclasses, proper logging, f‑strings, the built‑in tomllib, and the transition from distutils to setuptools—showing why and how to adopt them in everyday code.
LoggingPythondataclasses
0 likes · 15 min read

This article compares six Python alternatives to traditional classes—plain classes, tuples, dictionaries, named tuples, attrs, dataclasses, and Pydantic—examining their syntax, validation capabilities, mutability, string representation, JSON (de)serialization, memory usage, and performance to help developers choose the most suitable data‑modeling approach.
ClassesPydanticPython
0 likes · 17 min read

This article presents fifteen practical Python techniques—including multi‑key sorting, data classes, list comprehensions, memory inspection, frequency analysis, attrs usage, dictionary merging, multiple return values, filtering, mapping, zipping, reversing, existence checks, flattening nested lists, and uniqueness testing—each illustrated with clear code examples and explanations.
dataclassesdictionaryfunctions
0 likes · 15 min read
