Skip to main content

Dictionary as an object, that can have different views

Project description

Dictionaries as objects, that can have different dictionary views!


$ pip install thingy


Dictionaries as objects…

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

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

>>> = "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 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.


To run Thingy tests:

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



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Thingy, version 0.8.5
Filename, size File type Python version Upload date Hashes
Filename, size Thingy-0.8.5-py2.py3-none-any.whl (5.4 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size Thingy-0.8.5.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page