tabl
TABL implementation in Python.
Table of Contents
Background
TABL is a data serialization language inspired by Lua's table data structure and Python's syntax.
Install
Install via pip:
pip install tabl-lang
tabl-lang requires Python 3.8+, and automatically installs lark-parser, a library for generating parsers, as a dependency.
Usage
Import:
>>> import tabl
Load a table from string:
>>> tabl.loads("name = 'Owen', location: 'Halifax', 'Nova Scotia', 'Canada'")
Table(location=Table('Halifax', 'Nova Scotia', 'Canada'), name='Owen')
Print a table:
>>> tabl.dumps(tabl.Table(location=tabl.Table('Halifax', 'Nova Scotia', 'Canada'), name='Owen'))
"name = 'Owen', location: 'Halifax', 'Nova Scotia', 'Canada'"
The print function can also take in sets, lists, and dicts:
>>> tabl.dumps({'location': ['Halifax', 'Nova Scotia', 'Canada'], 'name': 'Owen'})
"name = 'Owen', location: 'Halifax', 'Nova Scotia', 'Canada'"
The table
class has several handy methods that allow its instances to be treated like sets, lists, or dicts, interchangeably.
Contributing
N/A
License
MIT © Owen Maitzen