launch.substitutions.python_expression module

Module for the PythonExpression substitution.

class launch.substitutions.python_expression.PythonExpression[source]

Bases: Substitution

Substitution that can access contextual local variables.

The expression may contain Substitutions, but must return something that can be converted to a string with str(). It also may contain math symbols and functions.

__init__(expression: str | Substitution | Iterable[str | Substitution], python_modules: str | Substitution | Iterable[str | Substitution] = ['math']) None[source]

Create a PythonExpression substitution.

describe() str[source]

Return a description of this substitution as a string.

property expression: List[Substitution]

Getter for expression.

classmethod parse(data: Sequence[str | Substitution | Iterable[str | Substitution]])[source]

Parse PythonExpression substitution.

perform(context: LaunchContext) str[source]

Perform the substitution by evaluating the expression.

property python_modules: List[Substitution]

Getter for python modules.