skillfed

fields

Container class boilerplate killer.

fields v5.0.0 78.8K downloads/30d#14,411 on PyPI137
Permissive license BSD Abandoned released

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 fields

uv

uv add fields

poetry

poetry add fields

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Utilities

Tags

container class boilerplateautomatic repr and equalitylightweight data classfield initialization syntaxnamedtuple alternativeclass decorator-free fieldssimple object containers
legacydata-structures

More Utilities packages