Thingy
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
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)
| File | Size | Uploaded | |
|---|---|---|---|
| Thingy-0.10.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|