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
Thingy-0.10.0.tar.gz 4.6 kB 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

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

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