simplestr
A python package with annotations to automatically generate __str__(self), __repr__(self) and __eq__(self, other) methods in classes
Description
This package provides only two annotations:
@gen_strto generate__str__(self)method@gen_reprto generate__repr__(self)method@gen_eqto generate__eq__(self, other)method@gen_str_reprto generate both__str__(self)and__repr__(self)methods@gen_str_repr_eqto generate both__str__(self),__repr__(self)and__eq__(self, other)methods
Installation
Normal installation
pip install simplestr
Development installation
git clone https://github.com/jpleorx/simplestr.git
cd simplestr
pip install --editable .
Example A (with separate annotations)
from simplestr import gen_str, gen_repr, gen_eq
@gen_str
@gen_repr
@gen_eq
class Rect:
def __init__(self, x: int, y: int, w: int, h: int):
self.x = x
self.y = y
self.w = w
self.h = h
rect1 = Rect(1, 2, 3, 4)
rect2 = Rect(10, 20, 30, 40)
print(rect1)
print(rect2)
print([rect1, rect2])
print(rect1 == rect2)
print(rect1 == Rect(1, 2, 3, 4))
Rect{x=1, y=2, w=3, h=4}
Rect{x=10, y=20, w=30, h=40}
[Rect{x=1, y=2, w=3, h=4}, Rect{x=10, y=20, w=30, h=40}]
False
True
Example B (with joined annotation)
from simplestr import gen_str_repr_eq
@gen_str_repr_eq
class Rect:
def __init__(self, x: int, y: int, w: int, h: int):
self.x = x
self.y = y
self.w = w
self.h = h
rect1 = Rect(1, 2, 3, 4)
rect2 = Rect(10, 20, 30, 40)
print(rect1)
print(rect2)
print([rect1, rect2])
print(rect1 == rect2)
print(rect1 == Rect(1, 2, 3, 4))
Rect{x=1, y=2, w=3, h=4}
Rect{x=10, y=20, w=30, h=40}
[Rect{x=1, y=2, w=3, h=4}, Rect{x=10, y=20, w=30, h=40}]
False
True
Links
In case you’d like to check my other work or contact me:
Metadata
Release files for simplestr 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplestr-0.5.0.tar.gz | 9.2 kB | Without provenance | Details for simplestr-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simplestr-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for simplestr-0.5.0-py3-none-any.whl |
Total release size: 19.0 kB
Release files / simplestr-0.5.0.tar.gz
| Download URL | simplestr-0.5.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48181febdc823b396e8aa1a2430c39a6b03c043d02750d0a2be824e82877bbdd
|
|
BLAKE2b-256 checksum How to use checksums |
9403b81c32ba928c3e63c175b0a103646ad083caafbbe3cf9c73a2a33f869900
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
|
Release files / simplestr-0.5.0-py3-none-any.whl
| Download URL | simplestr-0.5.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7e4713b88762c6e798901acfbaca84e444ee8f95f2122420327d022c33217e5
|
|
BLAKE2b-256 checksum How to use checksums |
ea85f9358fe0106d54a55836bab6449c1d322f4618f5563778044ccb35011b4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
|
Security for simplestr 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.