I would like to create a simple file format/DSL which would allow my users to input data. My system is in python and using python’s parser is appealing. Syntax like this for defining a data element seems quite convenient.
Allocation(Param1 = Val1, Param2 = Val2 )
However, it does not support param names with spaces.
Allocation(Param 1 = Val1, Param 2 = Val2 )
Python parser friendly versions can look as follows, but not very user friendly.
Allocation(('Param 1',Val1), ('Param 2',Val1) ) Allocation(**{'Param 1':Val1, 'Param 2':Val1} )
Is there a way to make this more readable in python?
Here’s my preference.
These are relatively easy class declarations to create. The resulting structure is pleasant to process, too.