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

PythonObject -- a python object

Description

This type corresponds to all objects of the PyObject type in the Python C API, and in particular all of the types that users are familiar with from the Python language itself.

You can perform basic arithmetic on python objects.

i1 : x = pythonValue "5"

o1 = 5

o1 : PythonObject of class int
i2 : y = pythonValue "2"

o2 = 2

o2 : PythonObject of class int
i3 : x + y

o3 = 7

o3 : PythonObject of class int
i4 : x - y

o4 = 3

o4 : PythonObject of class int
i5 : x * y

o5 = 10

o5 : PythonObject of class int
i6 : x / y

o6 = 2.5

o6 : PythonObject of class float

You can also compare them.

i7 : x > y

o7 = true
i8 : x == y

o8 = false

You can also perform operations on python objects and Macaulay2 things. The results will be returned as python objects.

i9 : x + 2

o9 = 7

o9 : PythonObject of class int

Note that many keywords in Macaulay2 are mapped to a certain dunder method in Python. In particular,

Methods that use a python object:

  • ?? PythonObject (missing documentation)
  • abs(PythonObject) -- absolute value of a python object
  • ceiling(PythonObject) -- ceiling of a python object
  • describe(PythonObject) (missing documentation)
  • expression(PythonObject) (missing documentation)
  • floor(PythonObject) -- floor of a python object
  • getattr(PythonObject,String) -- see getattr -- get an attribute of a python object
  • PythonObject @@ Thing -- see getattr -- get an attribute of a python object
  • getitem(PythonObject,Thing) -- see getitem -- get elements of python sequences
  • PythonObject _ Thing -- see getitem -- get elements of python sequences
  • hasattr(PythonObject,String) -- see hasattr -- whether a python object has an attribute
  • help(PythonObject) -- documentation for python object
  • isMember(PythonObject,PythonObject) -- see isMember(Thing,PythonObject) -- test membership in a python object
  • isMember(Thing,PythonObject) -- test membership in a python object
  • iterator(PythonObject) -- get iterator of iterable python object
  • length(PythonObject) -- returns the length of a python object
  • net(PythonObject) (missing documentation)
  • next(PythonObject) -- retrieve the next item from a python iterator
  • + PythonObject
  • - PythonObject
  • PythonObject % PythonObject
  • PythonObject % Thing
  • PythonObject & PythonObject
  • PythonObject & Thing
  • PythonObject * PythonObject
  • PythonObject * Thing
  • PythonObject + PythonObject
  • PythonObject + Thing
  • PythonObject - PythonObject
  • PythonObject - Thing
  • PythonObject / PythonObject
  • PythonObject / Thing
  • PythonObject // PythonObject
  • PythonObject // Thing
  • PythonObject << PythonObject
  • PythonObject << Thing
  • PythonObject == PythonObject
  • PythonObject == Thing
  • PythonObject >> PythonObject
  • PythonObject >> Thing
  • PythonObject ? PythonObject
  • PythonObject ? Thing
  • PythonObject @ PythonObject
  • PythonObject @ Thing
  • PythonObject ^ PythonObject
  • PythonObject ^ Thing
  • PythonObject ^^ PythonObject
  • PythonObject ^^ Thing
  • PythonObject | PythonObject
  • PythonObject | Thing
  • PythonObject and PythonObject
  • PythonObject and Thing
  • PythonObject or PythonObject
  • PythonObject or Thing
  • PythonObject xor PythonObject
  • PythonObject xor Thing
  • Thing % PythonObject
  • Thing & PythonObject
  • Thing * PythonObject
  • Thing + PythonObject
  • Thing - PythonObject
  • Thing / PythonObject
  • Thing // PythonObject
  • Thing << PythonObject
  • Thing == PythonObject
  • Thing >> PythonObject
  • Thing ? PythonObject
  • Thing @ PythonObject
  • Thing ^ PythonObject
  • Thing ^^ PythonObject
  • Thing | PythonObject
  • Thing and PythonObject
  • Thing or PythonObject
  • Thing xor PythonObject
  • PythonObject %= Thing (missing documentation)
  • PythonObject &= Thing (missing documentation)
  • PythonObject *= Thing (missing documentation)
  • PythonObject += Thing (missing documentation)
  • PythonObject -= Thing (missing documentation)
  • PythonObject //= Thing (missing documentation)
  • PythonObject /= Thing (missing documentation)
  • PythonObject <<= Thing (missing documentation)
  • PythonObject >>= Thing (missing documentation)
  • PythonObject @= Thing (missing documentation)
  • PythonObject ^= Thing (missing documentation)
  • PythonObject ^^= Thing (missing documentation)
  • PythonObject |= Thing (missing documentation)
  • PythonObject ~ -- bitwise not of a python object
  • quotientRemainder(PythonObject,PythonObject) -- quotient and remainder of python objects
  • quotientRemainder(PythonObject,Thing) -- see quotientRemainder(PythonObject,PythonObject) -- quotient and remainder of python objects
  • quotientRemainder(Thing,PythonObject) -- see quotientRemainder(PythonObject,PythonObject) -- quotient and remainder of python objects
  • round(PythonObject) -- see round(ZZ,PythonObject) -- round a python object
  • round(PythonObject,PythonObject) -- see round(ZZ,PythonObject) -- round a python object
  • round(ZZ,PythonObject) -- round a python object
  • PythonObject @@ Thing = Thing -- see setattr -- set an attribute of a python object
  • setattr(PythonObject,String,Thing) -- see setattr -- set an attribute of a python object
  • PythonObject _ Thing = Thing -- see setitem -- set elements of mutable python sequences
  • setitem(PythonObject,Thing,Thing) -- see setitem -- set elements of mutable python sequences
  • texMath(PythonObject) (missing documentation)
  • toExternalString(PythonObject) (missing documentation)
  • PythonObject Thing -- see toFunction -- convert callable python objects to Macaulay2 functions
  • toFunction(PythonObject) -- see toFunction -- convert callable python objects to Macaulay2 functions
  • toPython(PythonObject) -- see toPython -- convert Macaulay2 things to Python objects
  • toString(PythonObject) (missing documentation)
  • truncate(PythonObject) -- truncate a python object
  • value(PythonObject) -- convert python objects to Macaulay2 things

For the programmer

The object PythonObject is a type, with ancestor class Thing.


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