Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A collection of super mutables

Project Description

This library works with python 2.6, 2.7 and 3.2.

It defines three kinds of mutables.


The dot module contains classes that allow dot-notation to be used for when accessing a list or dict object.


>>  from import dotify
>>  d = dotify({'a':[1, 2, 3, 4, 5], 'b': {'c': 5}})
>>  d.a._0
>>  d.b.c
>>  d.c = {'f': 9}
>>  d.c.f


The readonly module contains classes that transform dict and list objects into ones that cannot have any values changed on them.


>>  from supermutes.readonly import readonly
>>  r = readonly({'a':[1, 2, 3, 4, 5], 'b': {'c': 5}})
>>  r
{'a': [1, 2, 3, 4, 5], 'b': {'c': 5}}
>>  r['a'].append(5)
supermutes.readonly.ReadOnlyClassException: Cannot write to object.
>> r['b']['d'] = 6
supermutes.readonly.ReadOnlyClassException: Cannot write to object.

A decorator function is also available for readonly objects. It will readonly-fy the output of the decorated function/method


from supermutes.decorators import return_readonly

def get_list():
    return ['12']


The ordered module contains the OrderedDefaultDict class. It is an implementation that is meant to be the child of an OrderedDict and a defaultdict from the python standard library.

Creating Sub Classes

Upon declaration of a sub class of any of the supermutes, that class will be set as the defacto class for recursively changing data sets.

To reset the classes back to the original set, use the reset_mapping method inside the module


>>> from import DotDict, DotList, reset_mapping
>>> class MySubClass(DotDict): pass
>>> d = MySubClass({'a': {'b': {'c': 3}}})
>>> d.a.b
{'c': 3}
>>> d.a.b.__class__
<class '__main__.MySubClass'>
>>> f = DotList([1, {}])
>>> f[1].__class__
<class '__main__.MySubClass'>
>>> reset_mapping()
>>> f = DotList([1, {}])
>>> f[1].__class__
<class ''>

Writing your own Supermutable

If you would like to contribute, and write a supermutable that behaves in a particular fashion, just try to follow these guidelines:

  • It should inherit from the mutable type that it is adapting (eg dict list etc.)
  • It should also inherit from base.SuperMutable. This takes care of all of the registering of any subclasses so that for example, all sub dicts added to the SuperMutable are changed accordingly. See for a working sample.


After cloning the repo:

$ pip install -r test-requirements.txt
$ nosetests

supermutes has a build job at

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.3 kB) Copy SHA256 Hash SHA256
Source None May 7, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate