Use json files with the import statement
Project description
Have you ever been kept awake at night, desperately feeling a burning desire to do nothing else but directly import JSON files as if they were python modules [1]? Now you can!
This abomination allows you to write
import some_json_file
and if some_json_file.json can be found, it will be available as if it is a python module.
Usage
Slap a json file somewhere on your python path. tester.json:
{
"hello": "world",
"this": {
"can": {
"be": "nested"
}
}
}
Now import jsonsempai and your json file!
>>> from jsonsempai import magic
>>> import tester
>>> tester
<module 'tester' from 'tester.json'>
>>> tester.hello
u'world'
>>> tester.this.can.be
u'nested'
>>>
Alternatively, a context manager may be used (100% less magic):
>>> import jsonsempai
>>> with jsonsempai.imports():
... import tester
>>> tester
<module 'tester' from 'tester.json'>
Installing
Install from pip:
$ pip install json-sempai
or clone this repo and install from source:
$ python setup.py install
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
json-sempai-0.2.0.tar.gz
(3.2 kB
view hashes)