Skip to main content

\

Project description

Sometimes, you want to use a mapping object like a regular object.

zc.mappingobject provides a wrapper for a mapping objects that provides both attribute and item access.

>>> import zc.mappingobject
>>> mapping = dict(a=1)
>>> ob = zc.mappingobject.mappingobject(mapping)
>>> ob.a
1
>>> ob.a = 2
>>> ob.a
2
>>> mapping
{'a': 2}
>>> list(ob)
['a']
>>> len(ob)
1
>>> ob['a'] = 3
>>> ob.a
3
>>> mapping
{'a': 3}
>>> del ob.a
>>> mapping
{}
>>> ob.a
Traceback (most recent call last):
...
AttributeError: a
>>> ob.b = 1
>>> mapping
{'b': 1}
>>> del ob['b']
>>> mapping
{}

Project details


Download files

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

Source Distribution

zc.mappingobject-1.0.0.tar.gz (2.2 kB view hashes)

Uploaded source

Supported by

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