Macaulay2 » Documentation
Packages » Python » PythonObject » toExternalString(PythonObject)
next | previous | forward | backward | up | index | toc

toExternalString(PythonObject) -- unambiguous string representation of a python object

Description

This returns a string beginning with pythonValue and that uses Python's builtin repr function to obtain a string that potentially may be evaluated using value(String) to return a Python object equal to x.

i1 : hello = toPython "Hello, world!"

o1 = Hello, world!

o1 : PythonObject of class str
i2 : toExternalString hello

o2 = pythonValue "'Hello, world!'"
i3 : value oo

o3 = Hello, world!

o3 : PythonObject of class str

Note that describe does essentially the same thing, but returns a Describe object.

i4 : describe hello

o4 = pythonValue 'Hello, world!'

See also

Ways to use this method:


The source of this document is in Python/doc/string.m2:64:0.