Shared & Local Variables
In Cauldron, all variables are local within a step unless you explicitly share them. If we have a notebook step named "S01.py" that contains the following code:
STEP 1:
S01.py
01
02
import cauldron as cd x = 12
And we want to share the x variable with the "S02.py" step, we might expect this to work:
STEP 2:
S02.py
01
02
import cauldron as cd print(x)
But if you run this notebook, the "S02.py" step will raise an error because the x variable is not defined in that step. It needs to be explicitly shared between the steps by using Cauldron's shared module like this:
STEP 1:
S01.py
01
02
import cauldron as cd cd.shared.x = 12
We can then access the variable in "S02.py" by accessing the variable from Cauldrons shared module:
STEP 2:
S02.py
01
02
import cauldron as cd print(cd.shared.x)
Now "S02.py" correctly prints a value of 12 to the notebook.