Skip to main content

PEP-557 compatible dataclasses backport for Python 2.7+

Project description

py2dataclasses

This project is a PEP-557 compatible dataclass implementation for Python 2.7.

Usage

On Python 2.7 there is no annotation syntax (x: int), so fields are declared using field() descriptors:

from dataclasses import dataclass, field

@dataclass
class Point(object):
    x = field(int)
    y = field(int)

p = Point(3, 4)
print(p)        # Point(x=3, y=4)
print(p.x)      # 3
print(p == Point(3, 4))  # True

Disclaimer

Sometimes systems have a proprietary legacy that is not possible to port to newer versions of languages. But people still need to work, systems using python 2 still have to be supported and extended.

⚠ WARNING

  • Please, DO NOT use Python 2.7 in 2026

Development

  • This is quite a straightforward convertion of dataclasses into a py2 syntax/standard done initially by neural network, and after that it was reviewed, fixed and finished by human.
  • Tests are taken from the cpython 3.14 branch and converted to py2

Testing

  • This project aims to pass all the tests from Python 3.14
  • It also aims to pass all backported tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py2dataclasses-3.14.112.tar.gz (106.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

py2dataclasses-3.14.112-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

py2dataclasses-3.14.112-py2-none-any.whl (32.8 kB view details)

Uploaded Python 2

File details

Details for the file py2dataclasses-3.14.112.tar.gz.

File metadata

  • Download URL: py2dataclasses-3.14.112.tar.gz
  • Upload date:
  • Size: 106.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for py2dataclasses-3.14.112.tar.gz
Algorithm Hash digest
SHA256 bcaeb201377f3ace063808bd89cceee4ed4d7adf018f0175d61d703495c8686c
MD5 f1a1237a6b1aef7adcc1d7be566d163b
BLAKE2b-256 0b6bcf1b5d323053337cd0dd68bd6f866a5fee57a3e3e8751fc7c72781461171

See more details on using hashes here.

File details

Details for the file py2dataclasses-3.14.112-py3-none-any.whl.

File metadata

File hashes

Hashes for py2dataclasses-3.14.112-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb92b14446b8a4697737ece854b47c0269cad026eb224cef88f5a46439bd193
MD5 adea817ff9a98afffc3d04b47d0798e9
BLAKE2b-256 24059ee6449b13a2b98a4116619b581c6e6aa8541ce7799790c97620d9fddd46

See more details on using hashes here.

File details

Details for the file py2dataclasses-3.14.112-py2-none-any.whl.

File metadata

File hashes

Hashes for py2dataclasses-3.14.112-py2-none-any.whl
Algorithm Hash digest
SHA256 fa207c30df4bbee295e97b56b6abda92b8af8b62a3dae39e744694ff6bf493b3
MD5 ff84740c940c5e63757e9806b3b67471
BLAKE2b-256 9d248753713210af9a893858a8d91de7b3ec2750efc394ff264bb9f59a1ab0be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page