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.4.tar.gz (7.7 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.4-py2-none-any.whl (9.2 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for attributedict-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2f8cb63a37c2543a85f7c9b9b0e2ea7b7646b371ef7ee38b91bd0ad8f70b5bbc
MD5 2e757c3f451142688c26886acf237f66
BLAKE2b-256 00e6793a47a3cadcfcdb908fdad8d4889f1120898bf87838e1e0e365f28ccb64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for attributedict-0.1.4-py2-none-any.whl
Algorithm Hash digest
SHA256 252b604723fbf2c66cfc4269920491eaa9e07067259ab5971be8ac36a82a218b
MD5 53de9ca53470f03d759dca94fa99f119
BLAKE2b-256 deaba322bf988cc24981501490b29e8f2a085c7f0dc72d578205e213a9d10850

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