Skip to main content

Thingy

https://img.shields.io/pypi/v/thingy.svg https://img.shields.io/github/license/Refty/thingy.svg https://img.shields.io/travis/Refty/thingy.svg https://img.shields.io/coveralls/Refty/thingy.svg https://readthedocs.org/projects/python-thingy/badge

Dictionaries as objects, that can have different dictionary views!

Install

$ pip install thingy

Examples

Dictionaries as objects…

>>> class MyThingy(Thingy)
...     @property
...     def foobaz(self):
...         return self.foo + self.baz

>>> thingy = MyThingy({"foo": "bar", "baz": "qux"})
>>> thingy.foo
"bar"
>>> thingy.foobaz
"barqux"

>>> thingy.foo = "BARRRR"
>>> thingy.view()
{"foo": "BARRRR", "baz": "qux"}

…that can have different dictionary views!

>>> MyThingy.add_view(name="fooz", include=["foo", "foobaz"])
>>> MyThingy.add_view(name="no_foo", defaults=True, exclude="foo")

>>> thingy = MyThingy({"foo": "bar", "baz": "qux"})
>>> thingy.view("fooz")
{"foo": "bar", "foobaz": "barqux"}
>>> thingy.view("no_foo")
{"baz": "qux"}

Why Thingy?

Because it’s much more enjoyable to write foo.bar than foo["bar"].

Thingy is mainly meant to be used inside other libraries to provide abstractions over dictionaries, which can be useful for writing ORMs or similar utilities.

Thingy’s views system is also particularly useful as-is when you intensively manipulate dictionaries and often restrict those dictionaries to a few redundant items.

Tests

To run Thingy tests:

  • install developers requirements with pip install -r requirements.txt;

  • run pytest.

Sponsors

Numberly

Refty

License

MIT

Metadata

Release files for Thingy 0.10.0

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

Source distribution (sdist)

Source distribution for Thingy 0.10.0
File Size Uploaded Provenance
Thingy-0.10.0.tar.gz 4.6 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 9.1 kB

Release files / Thingy-0.10.0.tar.gz

Download URL Thingy-0.10.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a372734da8e723ee5e2e6178dec5230b07195db8bf3121f23a44efb4d8aeac71
BLAKE2b-256 checksum
How to use checksums
8ba817bd2539b6c8d0cc23c875e8af8691ed400dca178fc56946b37616a336c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / Thingy-0.10.0-py3-none-any.whl

Download URL Thingy-0.10.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
438394e6bd415962f7558442a47680d9e87b661cbf3fa8831904205143a0459e
BLAKE2b-256 checksum
How to use checksums
76774c999ef19be1eab8b3ffdcf2cde77426030a0f4763061f54e92a97738912
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for Thingy 0.10.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.

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