How Template Variables Work
Generated Python
Use $SETTA_GENERATED_PYTHON
in a code block to specify where the generated Python code should go.

Here's the actual code that gets run:
def run_code():
low = 0
high = 100
random_value = numpy.random.randint(low=low, high=high)
print(random_value)
run_code()
Generated Python Imports
If inferImports
is enabled in your settings, then the inferred import statements are automatically added to the top of the code block that contains $SETTA_GENERATED_PYTHON
.
However, if you'd like to customize where the import statements appear, then you can use $SETTA_GENERATED_PYTHON_IMPORTS
.

Here's the actual code that gets run:
def run_code():
import numpy.random
import numpy
low = 0
high = 100
random_value = numpy.random.randint(low=low, high=high)
print(random_value)
run_code()
Referencing section metadata
Prefix a code block's section name with $
to access its metadata.
- Version name:
$section_name$version
- Code block import path:
$section_name$import_path
- Code block runtime file path:
$section_name$file_path
Here's an example using all 3:

Running the bash script (section named chilly_azure
) will print the following:
hello
value@static_blue
3.0
The hello
comes from the fn()
call, and the static_blue
is the currently selected version of the value
section.