Dictionary as an object, that can have different views
Project description
Dictionary as an object, that can have different dictionary views
Install
$ pip install thingy
Examples
Dictionary as an object…
>>> 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 views!
>>> MyThingy.define_view(name="fooz", include=["foo", "foobaz"])
>>> MyThingy.define_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"}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Thingy-0.1.0.tar.gz
(2.5 kB
view hashes)