constantly
Symbolic constants for Python with named text, numeric, and bit-flag values.
Repository Health
Technical Analysis
constantly is a small, focused Python library that provides symbolic constant support. It lets you define collections of named constants that carry meaningful values — plain symbolic names, numeric values, or bit flags — instead of relying on bare strings or integers scattered through your code.
Originally part of the Twisted project as twisted.python.constants, it was extracted into a standalone package so any project can use it without depending on Twisted. It offers NamedConstant, ValueConstant, and FlagConstant primitives grouped under Names, Values, and Flags containers, giving you readable, self-documenting constants with iteration, comparison, and bitwise flag composition.
What You Get
- NamedConstant / Names for purely symbolic named constants
- ValueConstant / Values for constants that carry an associated value
- FlagConstant / Flags for bitwise-composable flag constants
- Iteration over a collection’s members and lookup by name or value
- A tiny, dependency-free package usable outside of Twisted
Common Use Cases
- Replacing magic strings or integers with self-documenting constants
- Defining protocol or state enumerations that iterate and compare cleanly
- Modeling composable bit-flag options with bitwise operators
- Sharing Twisted-style constants in projects that don’t use Twisted
Under The Hood
Architecture - The library is implemented under constantly/ (primarily _constants.py) around a metaclass-driven container pattern: base container classes (Names, Values, Flags) collect their declared constant members (NamedConstant, ValueConstant, FlagConstant) at class-definition time, assign ordering, and expose iteration and lookup helpers. FlagConstant additionally implements bitwise or/and/xor to combine flags into composite values.
Tech Stack - Pure Python with no runtime dependencies, packaged with a modern pyproject.toml (plus a legacy setup.py) and tested across versions using tox. Documentation is published via Read the Docs.
Code Quality - The code is compact and stable, carrying a test suite under constantly/test and years of production hardening from its origin in Twisted. Its narrow scope keeps the surface easy to reason about and audit.
API Design - The API is declarative and readable: subclass Names/Values/Flags and assign class attributes to constant instances. Members then behave as first-class objects supporting comparison, iteration, and (for flags) bitwise composition, giving enum-like ergonomics with Twisted’s established semantics.
Used by 2 apps in this directory
Phase Console
Security · Devops
End-to-end encrypted secrets management for engineering teams — from local dev to Kubernetes production.
SWIRL
Search · Databases · Data Engineering
Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.