Skip to content

Commit

Permalink
Update readme with python bindings and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tiltingpenguin committed Oct 25, 2023
1 parent 9e9adf2 commit 4e8eeee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,29 @@ exists:

The API is written in plain C. The description can be found here :https://opensuse.github.io/libeconf/

## Bindings for other languages

- [Python](bindings/python3/) ([Documentation](bindings/python3/docs/python-libeconf.3))

## Python

There are bindings available for Python that can be installed as an RPM package or from pypi as **python-libeconf**.
Note that the pypi package does not ship with libeconf and it has to be installed seperately.

### Usage example

```
>>> import econf
>>> file = econf.read_file("examples/etc/example/example.conf", "=", "#")
>>> econf.get_groups(file)
['Another Group', 'First Group', 'Group']
>>> econf.get_keys(file, "Group")
['Bla', 'Welcome[la]', 'Welcome']
>>> econf.get_int_value(file, "Group", "Bla")
12311
>>> econf.set_int_value(file, "Group", "Bla", 5)
>>> econf.get_int_value(file, "Group", "Bla")
5
>>> econf.write_file(file, "examples/etc/example", "example_new.conf")
>>>
```

0 comments on commit 4e8eeee

Please sign in to comment.