Skip to content

Instantly share code, notes, and snippets.

@Sunno
Created June 13, 2013 20:01
Show Gist options
  • Save Sunno/5776859 to your computer and use it in GitHub Desktop.
Save Sunno/5776859 to your computer and use it in GitHub Desktop.
A child class from dict in python that add some extra features to dict, in this case conversion to json just create an instance and you have dict features together with new features.
'''
Created on 13/06/2013
@author: Alvaro Marquina
'''
import json
class dict2(dict):
'''
adds some functions to dict
'''
def to_json(self):
return json.dumps(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment