2026-06-06 19:07:58 +02:00
.. index :: path, variable's relative path, variable's full path
.. _variablepath:
2026-06-06 17:53:37 +02:00
Full or relative path
=====================
To access a variable, it is necessary to know which family or subfamily it belongs to.
2026-06-06 19:07:58 +02:00
Let's create some variables to illustrate this point.
2026-06-06 17:53:37 +02:00
.. code-block :: yaml
%YAML 1.2
---
version: 1.1
my_family: # A family
my_sub_family: # A family inside an other family
my_first_variable: # My first variable
my_second_variable: # My second variable
my_third_variable: # My third variable
2026-06-06 19:07:58 +02:00
my_fourth_variable: # My forth variable
2026-06-06 17:53:37 +02:00
...
So we have three variables.
2026-06-06 19:07:58 +02:00
Here the full paths are:
2026-06-06 17:53:37 +02:00
2026-06-06 19:07:58 +02:00
- `my_family.my_sub_family.my_first_variable`
- `my_family.my_sub_family.my_second_variable`
- `my_family.my_third_variable`
- `my_fourth_variable`
2026-06-06 17:53:37 +02:00
But in calculation it's often better to use :term: `relative path` .
.. glossary ::
relative path
In a calculation definition, a relative path defines the location of a variable relative to the family of the variable where the parameter is calculated.
2026-06-06 19:07:58 +02:00
Instead of starting from the root, it uses references like `_. (current family)`, `__ . (parent family)`, `__ _. (sub parent family)` and so on.
2026-06-06 17:53:37 +02:00
Relative paths are shorter and portable across custom type.
2026-06-06 19:07:58 +02:00
Now we can define the :term: `relative path` from the `my_first_variable` variable:
2026-06-06 17:53:37 +02:00
2026-06-06 19:07:58 +02:00
- `_.my_second_variable`
- `__.my_third_variable`
- `___.my_fourth_variable`
2026-06-06 17:53:37 +02:00
From the `my_third_variable` :
2026-06-06 19:07:58 +02:00
- `_.my_sub_family.my_first_variable`
- `_.my_sub_family.my_second_variable`
- `__.my_fourth_variable`
Finally from the `my_fourth_variable` :
2026-06-06 17:53:37 +02:00
2026-06-06 19:07:58 +02:00
- `_.my_family.my_sub_family.my_first_variable`
- `_.my_family.my_sub_family.my_second_variable`
- `_.my_family.my_third_variable`
2026-06-06 17:53:37 +02:00