supermutes

A collection of super mutables
Download

supermutes Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Alex Couper
  • Publisher web site:
  • https://github.com/alexcouper/

supermutes Tags


supermutes Description

supermutes is a Python module that defines two kinds of mutables.dotThe dot module contains classes that allow dot-notation to be used for when accessing a list or dict object.eg:>> from supermutes.dot import dotify>> d = dotify({'a':, 'b': {'c': 5}})>> d.a._01>> d.b.c5>> d.c = {'f': 9}>> d.c.f9readonlyThe readonly module contains classes that transform dict and list objects into ones that cannot have any values changed on them.eg:>> from supermutes.readonly import readonly>> r = readonly({'a':, 'b': {'c': 5}})>> r{'a': , 'b': {'c': 5}}>> r.append(5)supermutes.readonly.ReadOnlyClassException: Cannot write to object.>> r = 6supermutes.readonly.ReadOnlyClassException: Cannot write to object.Creating Sub ClassesUpon 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 moduleeg:>>> from supermutes.dot 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()>>> f.__class__< class '__main__.MySubClass' >>>> reset_mapping()>>> f = DotList()>>> f.__class__< class 'supermutes.dot.DotDict' >Product's homepage


supermutes Related Software