constantly
Symbolic constants in Python
What it is and what it does
Constantly provides a way to define and work with symbolic constants in Python—a more structured alternative to plain module-level variables or enums. It originated from the Twisted project's internal constant system and offers support for text values, numeric values, and bit flags organized into named collections. The library is pure Python with no external dependencies, making it lightweight and easy to integrate.
Developers use it when they need a clean, type-safe way to represent a fixed set of named values—such as status codes, configuration options, or protocol flags—without the overhead of a full enum class. It's particularly useful in projects that already depend on Twisted or in codebases where enum semantics don't quite fit the use case.
Use it for:
- Define status codes or state constants that need to be grouped and referenced by name.
- Create bit flag constants for protocol or permission systems where multiple flags combine.
- Build configuration option sets that are safer than raw strings or integers.
- Organize numeric constants (e.g., error codes) into named collections for clarity.
- Replace ad-hoc constant definitions in Twisted-based projects with a standard library.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides symbolic constant support in Python, including collections and constants with text, numeric, and bit flag values.
Yes, if you need a lightweight, dependency-free way to define symbolic constants. The library is actively maintained, has no security vulnerabilities, and works across modern Python versions. It's worth installing for projects that benefit from structured constant definitions—particularly those already using Twisted or preferring this API over Python's built-in enum module.
Install
constantly on PyPI
pip
pip install constantlyuv
uv add constantlypoetry
poetry add constantlyInstalling constantly
Before you install
Low install friction; pure Python wheel with no runtime dependencies. Active maintenance with recent commits; last release 1021 days ago but repository remains current.
License in practice
MIT license (permissive); you can use this freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install constantly
from constantly import ValueConstant, Names
class Colors(Names):
RED = ValueConstant()
GREEN = ValueConstant()
BLUE = ValueConstant()
Requires Python 3.8 or later.
Verify before relying
- Whether the package's constant syntax and API remain stable for long-term use in large codebases.
- Performance characteristics when working with very large constant collections.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,021 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 14,174,793/month — #1,244 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: constantly-23.10.4-py3-none-any.whl
Keywords: constants, enum, twisted
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
aenumaenum provides advanced enumeration types…
permissive · top 1,000 on PyPI
enum34Provides enumeration support for older Python…
permissive · top 5,000 on PyPI
ntstatusProvides Python constants and lookup methods…
permissive · top 15,000 on PyPI
backports.strenumProvides StrEnum, a string-based enumeration…
permissive · top 5,000 on PyPI
constantdictProvides an immutable dictionary class that…
permissive · top 15,000 on PyPI
symenginePython wrappers for SymEngine, a fast C++…
permissive · top 15,000 on PyPI
fxpmathFxpmath provides fixed-point arithmetic with…
permissive · top 15,000 on PyPI
pytest-twistedA pytest plugin that enables testing of…
permissive · top 15,000 on PyPI
sed4onnxEncodes and decodes Base64-formatted constant…
permissive · top 15,000 on PyPI
enum-compatConditionally installs enum34 on Python…
permissive · top 5,000 on PyPI