Skip to content

Archive

Configuration

4 articles
Python 09 Sep 2026 10 min read

Reload Process Environment Variables with Python 3.14

Python applications often treat environment variables as if every read goes straight to the operating system. In CPython, that mental model is incomplete. os.environ is a mapping captured when the os module is first imported, normally during interpreter startup. If the process environment later changes through something outside that mapping, Python’s cached view can become stale. Python 3.14 adds os.reload_environ() for the unusual cases where an application really needs to refresh that view.

Python 08 Sep 2026 8 min read

Parse TOML Configuration Safely with Python tomllib

Python 3.11 added tomllib, giving applications a standard-library parser for TOML configuration files. That removes a dependency for a common task, but parsing is only one part of loading configuration correctly. A configuration loader still needs to decide how large an input may be, what keys and types are accepted, whether floating-point values require exact decimal semantics, and how syntax errors should be reported. It also needs to remember that tomllib reads TOML; it is not a TOML writer or a schema validator.

Python 03 Sep 2026 11 min read

Layer Configuration Safely with Python ChainMap

Applications often build configuration from several sources. Command-line arguments may override environment-derived values, which in turn override built-in defaults. A straightforward implementation copies dictionaries and applies update() repeatedly. That works, but copying hides an important part of the design: configuration is not merely one dictionary. It is a precedence chain of independent sources. Python’s collections.ChainMap makes that relationship explicit. It presents several mappings as one lookup view without merging them first.

Go 01 Sep 2026 5 min read

Reliable Application Configuration from Environment Variables in Go

Environment variables are a convenient way to configure deployed Go services, but calling os.Getenv throughout an application makes configuration difficult to validate and test. A stronger pattern is to load configuration once at startup, parse it into typed fields, validate all invariants, and pass the resulting value to the components that need it. The examples below use only the Go standard library and work with modern supported Go releases. Keep configuration in a typed struct Suppose a service needs a listen address, request timeout, and optional log level: