Mercurial > hgrepos > Python > libs > ConfigMix
changeset 658:6102b767fc69
Basic documentation for the indexed list access
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Mon, 30 May 2022 13:23:53 +0200 |
| parents | 213f0ec3bbbc |
| children | b97e5f3bbc8e |
| files | docs/introduction.rst |
| diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/introduction.rst Mon May 30 13:19:19 2022 +0200 +++ b/docs/introduction.rst Mon May 30 13:23:53 2022 +0200 @@ -290,6 +290,26 @@ :py:meth:`~.Configuration.getvarl_s` quoting is neither needed and not supported. + +Direct Access to List Items +--------------------------- + +Direct access to list items is possible: + +- Directly use the integer list index in :py:meth:`~.Configuration.getvarl` + and its friends. +- Encode the index number to string format using the ``~INDEX~`` syntax and + use :py:meth:`~.Configuration.getvar` and its friends. + +Negative indexes are supported with Python semantics. + +Examples: + +- ``config.getvarl_s("mylist", 0)`` or ``config.getvar_s("mylist.~0~)"`` +- ``config.getvarl_s("mylist", -1)`` or ``config.getvar_s("mylist.~-1~")`` + + + .. _merging-deletions: Deletions
