Name | lazyrepr JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | Mixin class for concise object representation |
upload_time | 2025-01-08 04:31:46 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
mixin
repr
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python utilities for concise object representation
This library provides utilities to implement the `__repr__`
and ipython `_repr_pretty_` methods to represent objects in a concise manner.
The implementation is based on the class `__init__` method signature,
and will differentiate between positional and optional parameters
in order to make the representation as succinct as possible.
These methods are intended to be used on simple classes that map all their constructor arguments to attributes. Also note that `dataclasses` already implement a similar `__repr__` method by default.
## Usage
To add a basic representation to a class you can overrides its `__repr__` method with `lazy_repr` as follows:
```python
from lazyrepr import lazy_repr
class MyClass:
__repr__ = lazy_repr
...
```
To provide both `__repr__` and ipython `_repr_pretty_` for a class just inherit from `ReprMixin`
```python
from lazyrepr import ReprMixin
class MyList(ReprMixin):
def __init__(self, item=()):
self.items = list(items)
lst = MyList(range(3))
print(lst) # >>> MyList([0, 1 2])
```
## Examples
Examples notebooks are in the `extras` folder.
## Installation
You can install this package with `pip`.
```console
pip install lazyrepr
```
## Related Projects and Resources
- [easyrepr](https://github.com/chrisbouchard/easyrepr)
Python decorator to automatically generate repr strings
- [dataclasses](https://docs.python.org/3/library/dataclasses.html)
Python Data Classes
Raw data
{
"_id": null,
"home_page": null,
"name": "lazyrepr",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "mixin, repr",
"author": null,
"author_email": "furechan <furechan@xsmail.com>",
"download_url": null,
"platform": null,
"description": "# Python utilities for concise object representation\n\nThis library provides utilities to implement the `__repr__`\nand ipython `_repr_pretty_` methods to represent objects in a concise manner.\nThe implementation is based on the class `__init__` method signature,\nand will differentiate between positional and optional parameters\nin order to make the representation as succinct as possible.\n\nThese methods are intended to be used on simple classes that map all their constructor arguments to attributes. Also note that `dataclasses` already implement a similar `__repr__` method by default.\n\n\n## Usage\n\nTo add a basic representation to a class you can overrides its `__repr__` method with `lazy_repr` as follows:\n\n```python\nfrom lazyrepr import lazy_repr\n\nclass MyClass:\n __repr__ = lazy_repr\n ...\n```\n\nTo provide both `__repr__` and ipython `_repr_pretty_` for a class just inherit from `ReprMixin`\n\n```python\nfrom lazyrepr import ReprMixin\n\nclass MyList(ReprMixin):\n def __init__(self, item=()):\n self.items = list(items)\n\nlst = MyList(range(3))\nprint(lst) # >>> MyList([0, 1 2])\n```\n\n## Examples\n\nExamples notebooks are in the `extras` folder.\n\n## Installation\n\nYou can install this package with `pip`.\n\n```console\npip install lazyrepr\n```\n\n## Related Projects and Resources\n\n- [easyrepr](https://github.com/chrisbouchard/easyrepr)\nPython decorator to automatically generate repr strings \n- [dataclasses](https://docs.python.org/3/library/dataclasses.html)\nPython Data Classes\n",
"bugtrack_url": null,
"license": null,
"summary": "Mixin class for concise object representation",
"version": "0.0.3",
"project_urls": {
"homepage": "https://github.com/furechan/lazyrepr"
},
"split_keywords": [
"mixin",
" repr"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "db2cf63a333990fd66ba48a4f8ad68ba7a126c3b0d959f3c0feaca0a6fdab067",
"md5": "bac749b465b001d6af8bb546f7dfa72c",
"sha256": "1376d68e2e4cf32f404ce96e9750fff1d19fd7827383dd9cce461266dd99a388"
},
"downloads": -1,
"filename": "lazyrepr-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bac749b465b001d6af8bb546f7dfa72c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 3482,
"upload_time": "2025-01-08T04:31:46",
"upload_time_iso_8601": "2025-01-08T04:31:46.745075Z",
"url": "https://files.pythonhosted.org/packages/db/2c/f63a333990fd66ba48a4f8ad68ba7a126c3b0d959f3c0feaca0a6fdab067/lazyrepr-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-08 04:31:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "furechan",
"github_project": "lazyrepr",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "lazyrepr"
}