Skip to main content

trivrepr - a helper for generating repr() strings

[Home | GitLab | PyPI | ReadTheDocs]

Overview

The trivrepr module contains the TrivialRepr class that may be derived from to provide an implementation of __repr__() for simple classes that have all their attributes passed directly to the constructor.

import trivrepr

class KeyValue(trivrepr.TrivialRepr):
    def __init__(self, key, value, more='hi'):
        super(KeyValue, self).__init__()
        self.key = key
        self.value = value
        self.more = more

kv = KeyValue(key='key', value='val')
print(repr(kv))

This program will output:

KeyValue(key='key', value='val', more='hi')

The TrivialReprWithJson class adds a .to_json() method that returns the same fields that __repr__() will output as a dictionary.

Contact

The trivrepr library was written by Peter Pentchev. It is developed in a GitLab repository. This documentation is hosted at Ringlet with a copy at ReadTheDocs.

Metadata

Release files for trivrepr 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trivrepr 0.2.1
File Size Uploaded
trivrepr-0.2.1.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trivrepr 0.2.1
File Interpreter ABI Platform
trivrepr-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / trivrepr-0.2.1.tar.gz

Download URL trivrepr-0.2.1.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
744d32a8e21647cdf81a54788ac24c39f8f60a40e98cba72fa5ac7c323b0a8dd
BLAKE2b-256 checksum
How to use checksums
314456e14e44ce7b090d3bfc5e6e04c67810e408907971a190e6b7d748b3eca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / trivrepr-0.2.1-py3-none-any.whl

Download URL trivrepr-0.2.1-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7efba17d50bfefaf015654e02db304a5c0f6d374f9db59830b259598d4a0196e
BLAKE2b-256 checksum
How to use checksums
de737da081c3f7f2ab9ff530c67c4c03284daef4156818dd3d2f9f62073cc76e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page