Macaulay2 » Documentation
Packages » Python :: pythonValue
next | previous | forward | backward | up | index | toc

pythonValue -- execute Python source code from a string

Synopsis

Description

This function a is wrapper around the function PyRun_String from the Python C API.

i1 : pythonValue "2 + 2"

o1 = 4

o1 : PythonObject of class int

If a sequence is given, then its elements are converted to strings using toString and then joined using concatenate. You can see the expression sent to the Python interpreter by setting debugLevel to a positive value.

i2 : debugLevel = 1

o2 = 1
i3 : x = 5

o3 = 5
i4 : pythonValue("3 + ", x)
 -- python command: 3 + 5

o4 = 8

o4 : PythonObject of class int

See also

Ways to use pythonValue :

For the programmer

The object pythonValue is a method function with a single argument.