Skip to main content

Decorator factory to help create class __repr__ functions.

Project description

dynrepr

Decorator factory to help create class __repr__ functions.

Example Usage:

# old
class Point:
    def __init__(self, x: int, y: int):
        self.x = x
        self.y = y

print(Point(1, 2))
# <__main__.Point object at 0x848469690>

# new
from dynrepr import dynrepr

@dynrepr
class Point:
    def __init__(self, x: int, y: int):
        self.x = x
        self.y = y

print(Point(1, 2))
# Point(x=1, y=2)

Advanced Usage:

from dynrepr import dynrepr

@dynrepr('x', 'y')
class FilterValuesPoint:
    def __init__(self, x: int, y: int, z: int):
        self.x = x
        self.y = y
        self.z = z

print(FilterValuesPoint(4, 6, 8))
# FilterValuesPoint(x=4, y=6)

@dynrepr(filters=[lambda v: 4 < v < 8])
class FilteredSubclassPoint(FilterValuesPoint): pass

print(FilteredSubclassPoint(4, 6, 8))
# FilteredSubclassPoint(y=6)

Installation

pip install dynrepr

MIT License

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

dynrepr-1.0.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

dynrepr-1.0.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file dynrepr-1.0.0.tar.gz.

File metadata

  • Download URL: dynrepr-1.0.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dynrepr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7a3056bbd8e68c423aeedd12d8464d9db681e774fd4f3590d76a7c5ab4fa342d
MD5 7cece2b6d67f936e04bdb7a9850f15c8
BLAKE2b-256 b4ee40c85719216b7fcffd10c579f8f4ba18f888a5f29f67d4a64bd293e5988e

See more details on using hashes here.

File details

Details for the file dynrepr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dynrepr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dynrepr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7ecdfc81a9d3af221ca5f02efd8de014d6bc1bcca47c2b0fb4ac74a4545697
MD5 817f30ea8ba22e5e239b3f7cf02c3aff
BLAKE2b-256 670898583657a5517b7f5a2d2f8f4d079e5ed84515e0bbd40be029313af18d6e

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