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

toString(PythonObject) -- readable string representation of a python object

Description

This is equivalent to Python's builtin str function.

i1 : datetime = import "datetime"

o1 = <module 'datetime' from '/usr/lib/python3.12/datetime.py'>

o1 : PythonObject of class module
i2 : epoch = datetime@@"datetime"(1970, 1, 1)

o2 = 1970-01-01 00:00:00

o2 : PythonObject of class datetime.datetime
i3 : toString epoch

o3 = 1970-01-01 00:00:00

Note that expression, net, and texMath do essentially the same thing, but return an Expression, a Net, or a string for use in TeX code, respectively.

i4 : expression epoch

o4 = 1970-01-01 00:00:00

o4 : Expression of class Holder
i5 : net epoch

o5 = 1970-01-01 00:00:00
i6 : texMath epoch

o6 = \texttt{1970-01-01 00:00:00}

See also

Ways to use this method:


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