python data object notation. like json, but pythonic
Project description
pydon
Python data object notation. Like json, but pythonic
This package provides some basic tools for reading and writing python data objects to and from strings or files. A .pydon file or string is simply a string representation of python data. The pydon package is meant to provide similar functionality to json. Any pydon strings should be valid python expressions and must be parsable by the python AST’s literal_eval method. This means that pydon strings can safely contain data expressed as pytyhon literals.
Requirements
Python 3
Installing
Install using pip:
$ pip install pydon
Using
This package should be usable in a very similar manner to the json package:
import pydon
my_data = pydon.load_string("{'a': 1, 'b': '2', 'c': [4, 5, 6]}")
The load_file method may be used to load data from a file directly:
import pydon
my_data = pydon.load_file('some_file.pydon')
The dump_string method may be used to dump a pydon serializable data object to a string. The method can accept pprint format arguments:
import pydon
pydon.dump_string({'a': 1, 'b': '2', 'c': [4, 5, 6]}, width=1, indent=2)
This should result in the following output:
{ 'a': 1, 'b': '2', 'c': [4, 5, 6], }
The dump_file method may be used to dump a pydon serializable data object directly to a named file. The method can accept pprint format arguments as well:
import pydon
pydon.dump_file(
{'a': 1, 'b': '2', 'c': [4, 5, 6]},
'some_file.pydon',
width=1, indent=2,
)
Note that the .pydon extension is only used as a matter of convention. You may find it more useful to simply use the .py extension.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pydon-0.1.1rc1.tar.gz
.
File metadata
- Download URL: pydon-0.1.1rc1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9db25fbfaef3a65560be4ef690f4f5fd3dc0ffb7e50238ed1b67d924fdf370f |
|
MD5 | 7f0ee5277193344936041bb52ae454a1 |
|
BLAKE2b-256 | 4c62a341a1c2824702f044e896ab69361e8723a94299e8455ab3cb96c4267c0a |