GetVariable - Maple Help

Python

 GetVariable
 get a variable value from a Python session
 SetVariable
 set name=value in a Python session

 Calling Sequence GetVariable(n) SetVariable(n, v)

Parameters

 n - string or name v - expression

Description

 • The SetVariable command assigns n = v in the Python environment.  The value, v must be a Python object or something that can be translated into a Python data structure.
 • The GetVariable command fetches the variable named n from the current running Python session.  A data structure conversion of the value of n will happen if possible.
 • This function is part of the Python package, so it can be used in the short form GetVariable(..) only after executing the command with(Python). However, it can always be accessed through the long form of the command by using Python[GetVariable](..).

Examples

 > $\mathrm{with}\left(\mathrm{Python}\right):$
 > $\mathrm{SetVariable}\left("a",1\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{SetVariable}\left("b",2\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{EvalString}\left("r=a+b"\right)$
 ${3}$ (3)
 > $\mathrm{GetVariable}\left("r"\right)$
 ${3}$ (4)

Compatibility

 • The Python[GetVariable] and Python[SetVariable] commands were introduced in Maple 2018.