Skip to content

alex-sherman/fakedict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Fakedict

A Python module allowing the simple creation of dictionaries with getter/setter functions.

Install using pip:

pip install fakedict

Usage

Abstracting certain kinds of interactions as dictionary operations can be a useful tool for some applications. A simple example is handling a JSON file containing a dictionary. Rather calling json.dump and json.load, we'll instead use a dictionary abstraction for interacting with the file. Many other use cases exist, in fact this module was developed in order to be used with python-jrpc for the purpose of abstracting some RPC calls into dictionary operations.

JSON File Example

dict.json

{
  "key": "value"
}

reader.py

import fakedict
jfile = fakedict.JSONFile("dict.json")
print jfile["key"]
jfile["something"] = "faff"

This will print "value" and modify the contents of dict.json to the following:

{
  "key": "value",
  "something": "faff"
}

About

A Python module allowing the simple creation of dictionaries with getter/setter functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages