Provide a helper for creating repr() strings
Project description
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trivrepr-0.2.1.tar.gz.
File metadata
- Download URL: trivrepr-0.2.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
744d32a8e21647cdf81a54788ac24c39f8f60a40e98cba72fa5ac7c323b0a8dd
|
|
| MD5 |
c13a3ad4a0ae4355b2f2e5c82b7a3bed
|
|
| BLAKE2b-256 |
314456e14e44ce7b090d3bfc5e6e04c67810e408907971a190e6b7d748b3eca2
|
File details
Details for the file trivrepr-0.2.1-py3-none-any.whl.
File metadata
- Download URL: trivrepr-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7efba17d50bfefaf015654e02db304a5c0f6d374f9db59830b259598d4a0196e
|
|
| MD5 |
68157907a2efb0d0a56dffd8708e73e0
|
|
| BLAKE2b-256 |
de737da081c3f7f2ab9ff530c67c4c03284daef4156818dd3d2f9f62073cc76e
|