A reasonable configuration language
rcl-lang.org
configuration-language
json
1# Python bindings
2
3RCL includes a Python native module that can be used to load documents, similar
4to Python’s built-in `json` module. Although it is possible to export an
5<abbr>RCL</abbr> document to <abbr>JSON</abbr> and load it using `json.load`,
6there are a few reasons for using the module:
7
8 * Avoiding an intermediate file or spawning an additional process.
9 * Supporting a wider range of types. The module preserves set values and
10 dictionaries with non-string keys.
11
12The name of the module is `rcl`. See the [installation instructions][install]
13for how to get the Python module.
14
15[install]: installation.md#python-module-from-source
16
17## Value mapping
18
19RCL values map to the corresponding Python values where possible: strings to
20strings, dicts to dicts, listst to lists, etc. Other values map as follows:
21
22 * `null` maps to `None`.
23 * Numbers that are integral map to `int`.
24 * Numbers that have a decimal point map to `float`.
25 * Functions are not supported at this time, they can’t be returned to Python.
26
27## load_file
28
29 rcl.load_file(path: str) -> Any
30
31Evaluate the <abbr>RCL</abbr> expression in the file at the given file path.
32
33## loads
34
35 rcl.loads(src: str) -> Any
36
37Evaluate the <abbr>RCL</abbr> expression `src`, return the result. This is
38analogous to `json.loads`. TODO: Add a way to control the sandbox policy and
39tracer.