fields
Container class boilerplate killer.
What it is and what it does
Fields is a lightweight library for defining container classes—objects that hold a fixed set of named attributes—without writing repetitive `__init__`, `__repr__`, and comparison methods. You define a class by chaining attribute names as class attributes (e.g., `class Pizza(Fields.name.size)`), and Fields automatically generates the initialization logic, a readable string representation, and all comparison operators. It supports both positional and keyword arguments, optional fields with default values, and can generate tuple subclasses for immutable containers.
The package positions itself as a middle ground between namedtuple (which is verbose and inflexible) and decorator-based approaches like attrs or characteristic (which impose constraints on how you write `__init__`). Fields lets you override methods normally—including `__init__`—without the framework fighting you. However, the project has been abandoned since 2016 and is untested on modern Python versions, making it a legacy choice for new code.
Use it for:
- Define simple immutable data structures (using Tuple base) as a more readable alternative to namedtuple for small projects.
- Create lightweight container classes for function return values or intermediate data without writing boilerplate comparison and repr methods.
- Build tree or graph node classes with optional fields and defaults (e.g., binary tree nodes with left/right children defaulting to None).
- Prototype data models quickly when you need a class with fields but don't want decorator syntax or external dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates lightweight container classes with automatic `__repr__`, comparison methods, and field initialization from a fluent attribute-chain syntax, eliminating boilerplate for simple data holders.
No, not for new projects. While the package is stable and has no known vulnerabilities, it has been abandoned since 2016 with no maintenance or Python 3.8+ testing. Modern alternatives like dataclasses (standard library in Python 3.7+) or attrs are actively maintained, better integrated with type checkers, and offer richer features. Install only if you are maintaining legacy code that already depends on it.
Install
fields on PyPI
pip
pip install fieldsuv
uv add fieldspoetry
poetry add fieldsInstalling fields
Before you install
Installation is frictionless (pure Python wheel, no runtime dependencies). However, the package is abandoned—last release was 2016-04-13 and last commit 2021-11-11—so it will not receive bug fixes or support for modern Python versions beyond what was already compiled in.
License in practice
BSD license (permissive) imposes no significant restrictions on use, modification, or redistribution in most contexts.
Quickstart
from fields import Fields
class Pizza(Fields.name.size):
pass
p = Pizza("Pepperoni", "large")
print(p) # Pizza(name='Pepperoni', size='large')
Package is abandoned and untested on Python versions released after 2016; compatibility with modern Python (3.8+) is unverified.
Verify before relying
- Whether the package works reliably on Python 3.8 and later without modification or workarounds.
- Whether the fluent attribute-chain syntax (e.g., `Fields.name.size`) works as documented in all Python implementations listed in classifiers.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,775 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 78,769/month — #14,411 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fields-5.0.0-py2.py3-none-any.whl
Keywords: container, fields, object, class, boilerplate
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
cattrsConverts unstructured dictionaries into…
permissive · top 1,000 on PyPI
attrsattrs is a Python library that automatically…
permissive · top 100 on PyPI
django-deprecate-fieldsProvides a decorator to mark Django model…
permissive · top 5,000 on PyPI
namedlistCreates mutable or immutable named tuple-like…
permissive · top 15,000 on PyPI
optreeOpTree provides optimized utilities for…
permissive · top 5,000 on PyPI
attrA decorator that attaches metadata attributes…
permissive · top 15,000 on PyPI
cobbleCobble is a Python library for creating data…
permissive · top 5,000 on PyPI
tinselGenerates PySpark DataFrame schemas from Python…
permissive · top 15,000 on PyPI
recordclassRecordclass provides memory-efficient, mutable…
permissive · top 15,000 on PyPI
desertDesert generates marshmallow serialization…
permissive · top 15,000 on PyPI