Macaulay2 » Documentation
Packages » Python » PythonObject » PythonObject @@ Thing
next | previous | forward | backward | up | index | toc

PythonObject @@ Thing -- get an attribute of a python object

Description

Get an attribute of a Python object. In Python, the . operator is used. However, this operator has a special meaning in Macaulay2 and cannot be overloaded. Since @@ has similar precedence, it is used instead.

i1 : foo = toPython "Hello, world!"

o1 = Hello, world!

o1 : PythonObject of class str
i2 : foo@@upper()

o2 = HELLO, WORLD!

o2 : PythonObject of class str

Note that toString is called on y before it is used. Therefore, symbols and functions may be used as well as strings. Sometimes, however, it is necessary to use quotes, e.g., when using special "dunder" methods with double underscores. These would result in a Macaulay2 syntax error if left unquoted.

i3 : foo@@"__len__"()

o3 = 13

o3 : PythonObject of class int

Ways to use this method:


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