Posts
Python Basics: Sorting Records with operator
Sorting records often starts with choosing a field. Python’s operator module provides small helper functions that extract dictionary items or object attributes for sorted() to …
October 12, 2026
Python Basics: Inspecting Text with unicodedata
Two strings can look alike while containing different Unicode code points. Python’s unicodedata module helps inspect characters and normalize equivalent spellings. Use Python 3.12 …
October 12, 2026
Python Basics: Filling Text with string.Template
For a short message with a few named fields, string.Template provides simple dollar-sign placeholders. Keep the wording in a template and supply the values separately. Use Python …
October 12, 2026
Python Basics: Encoding Bytes with base64
Some text-based formats need binary data represented as printable characters. Python’s base64 module converts bytes to an ASCII representation and back. Use Python 3.12 or newer on …
October 12, 2026
Python Basics: Calculating Exact Ratios with fractions
A recipe or measurement can involve values such as one third. Python’s fractions module stores a rational number as an integer numerator and denominator, so calculations with these …
October 12, 2026
Python Basics: Understanding Shallow and Deep Copies
Before changing a list or dictionary, you may want a separate version. Python’s standard-library copy module helps control which parts become independent. Use Python 3.12 or newer …
October 12, 2026
Python Basics: Splitting Quoted Text with shlex
A small text command might contain a filename with spaces. Python’s standard-library shlex module helps separate words while respecting shell-style quotes. Use Python 3.12 or newer …
October 12, 2026
Python Basics: Matching Filename Patterns with fnmatch
Imagine receiving a list of export filenames and needing only the daily sales reports. Python’s standard-library fnmatch module checks strings against shell-style patterns. It does …
October 12, 2026
Python Basics: Inspecting Data with pprint
A long dictionary can be hard to scan in a terminal. Python’s pprint module formats nested data across lines, making it easier to inspect a script’s intermediate results. Use …
October 12, 2026
Python Basics: Comparing Text with difflib
A misspelled command or a changed settings line can be easier to handle with a small comparison tool. Python’s standard-library difflib module supplies suggestions, readable …
October 12, 2026