Skip to main content

A dictionary object with attributes support.

Project description

AttributeDict Build Status PyPI version

A dictionary object with attributes support.

Install

Install using pip:

$ pip install attributedict

Use

Example:

from attributedict.collections import AttributeDict

data = AttributeDict({'foo': {'bar': [1, 2, 3]}})

data.foo # => `{'bar': [1, 2, 3]}}`
data.foo.bar # => `[1, 2, 3]`

data.foo = {'baz': True}
data.foo = # => `{'baz': True}`

del data.foo.baz

# and/or...

data = AttributeDict({'foo': {'bar': [1, 2, 3]}})

data['foo'] # => `{'bar': [1, 2, 3]}}`
data['foo']['bar'] # => `[1, 2, 3]`

data['foo'] = {'baz': True}
data['foo'] = # => `{'baz': True}`

del data['foo']['baz']

# instance of `dict`...

isinstance(data, dict) # => True
isinstance(data, attributedict.collections.AttributeDict) # => True

isinstance(data.__dict__, dict) # => True
isinstance(data.__dict__, attributedict.collections.AttributeDict) # => False

# no need for custom encoders...

data = AttributeDict({'foo': {'bar': [1, 2, 3]}})

json.dumps(data) # => `{"foo": {"bar": [1, 2, 3]}}`
json.dumps(data.__dict__) # => `{"foo": {"bar": [1, 2, 3]}}`

# etc.

Test

Clone down source code and run:

$ make install
$ make test

License

Released under the MIT license.

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

attributedict-0.1.2.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

attributedict-0.1.2-py2-none-any.whl (2.1 kB view details)

Uploaded Python 2

File details

Details for the file attributedict-0.1.2.tar.gz.

File metadata

  • Download URL: attributedict-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for attributedict-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d10b2bfa28a7415f144f086ef9289102c8d26f54c3d1e60112a3f45839ecc4c0
MD5 14e55cf4fbeab207e1cca475246a6f2d
BLAKE2b-256 e7529008fb6aaf7fb4810d39ac8f23443152ced68437d4945ca3b35c60e349ce

See more details on using hashes here.

File details

Details for the file attributedict-0.1.2-py2-none-any.whl.

File metadata

File hashes

Hashes for attributedict-0.1.2-py2-none-any.whl
Algorithm Hash digest
SHA256 6034a649317bc40962d943628c463dee3947e6e3e7497ccedb32e7abf2bd5cef
MD5 0470ce5e90b3cfea2bf746cfd299fcdc
BLAKE2b-256 ea6c818c983c01c778b17030c27bc749c7014233341bfb037ca5c9b72eb5a8eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page