Skip to main content

A subclass of dict that allows object-style access to its entries

Project description


A subclass of dict that allows object-style access to its entries.


pipenv install attribute_dict


    from attribute_dict import AttributeDict
    sample_dict = AttributeDict({'foo': 'bar'})
    sample_dict # => AttributeDict({'foo': 'bar'})

    # The object is just subclassed from dict, and has all of the standard functions
    isinstance(sample_dict, dict) # => True

    # Create a new AttributeDict by "stacking" iterables
    # Each iterable will overwrite keys in the previous one (kwargs are processed last!)
    sample_dict = AttributeDict({'foo': 'foo'}, {'foo': 'ba', 'bar': 'foo'}, {'foo': 'bar'}, {'foobar': 'bar'}, foobar='foo')
    # => AttributeDict({'foo': 'bar', 'bar': 'foo', 'foobar': 'foo'})

    # Create a new AttributeDict by shallow-copying an existing one
    new_sample_dict = sample_dict.copy()
    new_sample_dict # => AttributeDict({'foo': 'bar', 'bar': 'foo', 'foobar': 'foo'})
    isinstance(new_sample_dict, AttributeDict) # => True

    # NOTE: Child values are NOT processed!
    sample_dict = AttributeDict({'foo': iterable_two})
    sample_dict # => AttributeDict({'foo': {'foo': 'ba', 'bar': 'foo'}}) # => {'foo': 'ba', 'bar': 'foo'}
    sample_dict.__class__.__name__ # => 'AttributeDict' # => 'dict'


Tests use nose2. Clone the Github project. Install dev dependencies, and run tests using the nose2 command.

pipenv install --dev
pipenv shell

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

attribute_dict-1.0.0.tar.gz (4.9 kB view hashes)

Uploaded source

Built Distribution

attribute_dict-1.0.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded py3

Supported by

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