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

# PythonObject -- a Python object

## Description

In Macaulay2, all Python objects have the class `PythonObject`. Their Python classes are displayed after they are printed.

    i1 : toPython 3

    o1 = 3

    o1 : PythonObject of class int

    i2 : toPython "foo"

    o2 = foo

    o2 : PythonObject of class str

### Menu

#### converting to Python objects

- toPython -- convert Macaulay2 things to Python objects

#### converting from Python objects

- value(PythonObject) -- convert python objects to Macaulay2 things
- toFunction -- convert callable python objects to Macaulay2 functions
- addPyToM2Function -- convenience function for adding value hooks

#### string functions

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

#### list functions

- PythonObject _ Thing -- get elements of python sequences
- PythonObject _ Thing = Thing -- set elements of mutable python sequences
- length(PythonObject) -- returns the length of a python object
- isMember(PythonObject,PythonObject) -- test membership in a python object
- delete(Thing,PythonObject) -- delete elements from mutable python sequences
- iterator(PythonObject) -- get iterator of iterable python object
- next(PythonObject) -- retrieve the next item from a python iterator

#### attributes

- objectType -- type of a python object
- PythonObject @@ Thing -- get an attribute of a python object
- PythonObject @@? Thing -- whether a python object has an attribute
- PythonObject @@ Thing = Thing -- set an attribute of a python object

#### arithmetic operators

- PythonObject + PythonObject -- add Python objects
- PythonObject - PythonObject -- subtract Python objects
- PythonObject * PythonObject -- multiply Python objects
- PythonObject @ PythonObject -- matrix multiplication of Python objects
- PythonObject / PythonObject -- true division of Python objects
- PythonObject // PythonObject -- floor division of Python objects
- PythonObject % PythonObject -- the modulo operator for Python objects
- quotientRemainder(PythonObject,PythonObject) -- get the quotient and remainder when dividing Python objects
- PythonObject ^ PythonObject -- exponentiation of Python objects
- abs(PythonObject) -- absolute value of a python object

#### bitwise operators

- PythonObject << PythonObject -- the left shift operator for Python objects
- PythonObject >> PythonObject -- the right shift operator for Python objects
- PythonObject & PythonObject -- bitwise conjunction of Python objects
- PythonObject | PythonObject -- bitwise disjunction of Python objects
- PythonObject ^^ PythonObject -- bitwise exclusive disjunction of Python objects
- PythonObject ~ -- bitwise negation of a python object

#### logical operators

- PythonObject and PythonObject -- logical conjunction of Python objects
- PythonObject or PythonObject -- logical disjunction of Python objects
- PythonObject xor PythonObject -- logical exclusive disjunction of Python objects
- not PythonObject -- logical negation of a python object

#### comparison operators

- PythonObject ? PythonObject -- compare Python objects
- PythonObject == PythonObject -- equality of Python objects
- ?? PythonObject -- null coalescing operator for Python objects

#### number-theoretic functions

- binomial(PythonObject,PythonObject) -- binomial coefficient for Python objects
- PythonObject ! -- factorial of a Python object
- gcd(PythonObject,PythonObject) -- greatest common divisor of Python objects
- lcm(PythonObject,PythonObject) -- least common multiple of Python objects

#### floating-point functions

- ceiling(PythonObject) -- ceiling of a python object
- floor(PythonObject) -- floor of a python object
- remainder(PythonObject,PythonObject) -- remainder of python objects
- `round(PythonObject)` -- see round(PythonObject,PythonObject) -- round a python object
- truncate(PythonObject) -- truncate a python object
- isFinite(PythonObject) -- whether a Python object is finite
- isInfinite(PythonObject) -- whether a Python object is infinite

#### power, exponential, and logarithmic functions

- exp(PythonObject) -- exponential of a python object
- expm1(PythonObject) -- exponential minus one of a python object
- `log(PythonObject)` -- see log(PythonObject,PythonObject) -- logarithm of a python object
- log1p(PythonObject) -- logarithm plus one of a python object
- sqrt(PythonObject) -- square root of a python object

#### trigonometric functions

- acos(PythonObject) -- arc cosine of a python object
- asin(PythonObject) -- arc sine of a python object
- atan(PythonObject) -- arc tangent of a python object
- atan2(PythonObject,PythonObject) -- arc tangent of quotient of python objects
- cos(PythonObject) -- cosine of a python object
- sin(PythonObject) -- sine of a python object
- tan(PythonObject) -- tangent of a python object

#### hyperbolic functions

- acosh(PythonObject) -- inverse hyperbolic cosine of a python object
- asinh(PythonObject) -- inverse hyperbolic sine of a python object
- atanh(PythonObject) -- inverse hyperbolic tangent of a python object
- cosh(PythonObject) -- hyperbolic cosine of a python object
- sinh(PythonObject) -- hyperbolic sine of a python object
- tanh(PythonObject) -- hyperbolic tangent of a python object

#### special functions

- erf(PythonObject) -- error function of a python object
- erfc(PythonObject) -- complementary error function of a python object
- Gamma(PythonObject) -- gamma function of a python object
- lngamma(PythonObject) -- natural logarithm of the gamma function of a python object

## Methods that use a python object:

- ?? PythonObject -- null coalescing operator for Python objects
- abs(PythonObject) -- absolute value of a python object
- acos(PythonObject) -- arc cosine of a python object
- acosh(PythonObject) -- inverse hyperbolic cosine of a python object
- `addPyToM2Function(PythonObject,Function,String)` -- see addPyToM2Function -- convenience function for adding value hooks
- asin(PythonObject) -- arc sine of a python object
- asinh(PythonObject) -- inverse hyperbolic sine of a python object
- atan(PythonObject) -- arc tangent of a python object
- atan2(PythonObject,PythonObject) -- arc tangent of quotient of python objects
- `atan2(PythonObject,Thing)` -- see atan2(PythonObject,PythonObject) -- arc tangent of quotient of python objects
- `atan2(Thing,PythonObject)` -- see atan2(PythonObject,PythonObject) -- arc tangent of quotient of python objects
- atanh(PythonObject) -- inverse hyperbolic tangent of a python object
- binomial(PythonObject,PythonObject) -- binomial coefficient for Python objects
- `binomial(PythonObject,Thing)` -- see binomial(PythonObject,PythonObject) -- binomial coefficient for Python objects
- `binomial(Thing,PythonObject)` -- see binomial(PythonObject,PythonObject) -- binomial coefficient for Python objects
- ceiling(PythonObject) -- ceiling of a python object
- cos(PythonObject) -- cosine of a python object
- cosh(PythonObject) -- hyperbolic cosine of a python object
- delete(Thing,PythonObject) -- delete elements from mutable python sequences
- erf(PythonObject) -- error function of a python object
- erfc(PythonObject) -- complementary error function of a python object
- exp(PythonObject) -- exponential of a python object
- expm1(PythonObject) -- exponential minus one of a python object
- floor(PythonObject) -- floor of a python object
- Gamma(PythonObject) -- gamma function of a python object
- `gcd(PythonObject)` -- see gcd(PythonObject,PythonObject) -- greatest common divisor of Python objects
- gcd(PythonObject,PythonObject) -- greatest common divisor of Python objects
- `gcd(PythonObject,Thing)` -- see gcd(PythonObject,PythonObject) -- greatest common divisor of Python objects
- `gcd(Thing,PythonObject)` -- see gcd(PythonObject,PythonObject) -- greatest common divisor of Python objects
- help(PythonObject) -- documentation for python object
- isFinite(PythonObject) -- whether a Python object is finite
- isInfinite(PythonObject) -- whether a Python object is infinite
- isMember(PythonObject,PythonObject) -- test membership in a python object
- `isMember(PythonObject,Thing)` -- see isMember(PythonObject,PythonObject) -- test membership in a python object
- `isMember(Thing,PythonObject)` -- see isMember(PythonObject,PythonObject) -- test membership in a python object
- iterator(PythonObject) -- get iterator of iterable python object
- `lcm(PythonObject)` -- see lcm(PythonObject,PythonObject) -- least common multiple of Python objects
- lcm(PythonObject,PythonObject) -- least common multiple of Python objects
- `lcm(PythonObject,Thing)` -- see lcm(PythonObject,PythonObject) -- least common multiple of Python objects
- `lcm(Thing,PythonObject)` -- see lcm(PythonObject,PythonObject) -- least common multiple of Python objects
- length(PythonObject) -- returns the length of a python object
- `listSymbols(PythonObject)` -- see listSymbols(PythonContext) -- get a table of all the variables and their values in a python context
- lngamma(PythonObject) -- natural logarithm of the gamma function of a python object
- `log(PythonObject)` -- see log(PythonObject,PythonObject) -- logarithm of a python object
- log(PythonObject,PythonObject) -- logarithm of a python object
- `log(PythonObject,Thing)` -- see log(PythonObject,PythonObject) -- logarithm of a python object
- `log(Thing,PythonObject)` -- see log(PythonObject,PythonObject) -- logarithm of a python object
- log1p(PythonObject) -- logarithm plus one of a python object
- next(PythonObject) -- retrieve the next item from a python iterator
- not PythonObject -- logical negation of a python object
- PythonObject ! -- factorial of a Python object
- PythonObject % PythonObject -- the modulo operator for Python objects
- `PythonObject % Thing` -- see PythonObject % PythonObject -- the modulo operator for Python objects
- `Thing % PythonObject` -- see PythonObject % PythonObject -- the modulo operator for Python objects
- PythonObject %= Thing -- augmented modulo operator for Python objects
- PythonObject & PythonObject -- bitwise conjunction of Python objects
- `PythonObject & Thing` -- see PythonObject & PythonObject -- bitwise conjunction of Python objects
- `Thing & PythonObject` -- see PythonObject & PythonObject -- bitwise conjunction of Python objects
- PythonObject &= Thing -- augmented bitwise conjunction of Python objects
- PythonObject * PythonObject -- multiply Python objects
- `PythonObject * Thing` -- see PythonObject * PythonObject -- multiply Python objects
- `Thing * PythonObject` -- see PythonObject * PythonObject -- multiply Python objects
- PythonObject *= Thing -- augmented multiplication of Python objects
- `+ PythonObject` -- see PythonObject + PythonObject -- add Python objects
- PythonObject + PythonObject -- add Python objects
- `PythonObject + Thing` -- see PythonObject + PythonObject -- add Python objects
- `Thing + PythonObject` -- see PythonObject + PythonObject -- add Python objects
- PythonObject += Thing -- augmented addition of Python objects
- `- PythonObject` -- see PythonObject - PythonObject -- subtract Python objects
- PythonObject - PythonObject -- subtract Python objects
- `PythonObject - Thing` -- see PythonObject - PythonObject -- subtract Python objects
- `Thing - PythonObject` -- see PythonObject - PythonObject -- subtract Python objects
- PythonObject -= Thing -- augmented subtraction of Python objects
- PythonObject / PythonObject -- true division of Python objects
- `PythonObject / Thing` -- see PythonObject / PythonObject -- true division of Python objects
- `Thing / PythonObject` -- see PythonObject / PythonObject -- true division of Python objects
- PythonObject // PythonObject -- floor division of Python objects
- `PythonObject // Thing` -- see PythonObject // PythonObject -- floor division of Python objects
- `Thing // PythonObject` -- see PythonObject // PythonObject -- floor division of Python objects
- PythonObject //= Thing -- augmented floor division of Python objects
- PythonObject /= Thing -- augmented true division of Python objects
- PythonObject << PythonObject -- the left shift operator for Python objects
- `PythonObject << Thing` -- see PythonObject << PythonObject -- the left shift operator for Python objects
- `Thing << PythonObject` -- see PythonObject << PythonObject -- the left shift operator for Python objects
- PythonObject <<= Thing -- augmented left shift for Python objects
- PythonObject == PythonObject -- equality of Python objects
- `PythonObject == Thing` -- see PythonObject == PythonObject -- equality of Python objects
- `Thing == PythonObject` -- see PythonObject == PythonObject -- equality of Python objects
- PythonObject >> PythonObject -- the right shift operator for Python objects
- `PythonObject >> Thing` -- see PythonObject >> PythonObject -- the right shift operator for Python objects
- `Thing >> PythonObject` -- see PythonObject >> PythonObject -- the right shift operator for Python objects
- PythonObject >>= Thing -- augmented right shift for Python objects
- PythonObject ? PythonObject -- compare Python objects
- `PythonObject ? Thing` -- see PythonObject ? PythonObject -- compare Python objects
- `Thing ? PythonObject` -- see PythonObject ? PythonObject -- compare Python objects
- PythonObject @ PythonObject -- matrix multiplication of Python objects
- `PythonObject @ Thing` -- see PythonObject @ PythonObject -- matrix multiplication of Python objects
- `Thing @ PythonObject` -- see PythonObject @ PythonObject -- matrix multiplication of Python objects
- PythonObject @= Thing -- augmented matrix multiplication of Python objects
- PythonObject @@ Thing -- get an attribute of a python object
- PythonObject @@ Thing = Thing -- set an attribute of a python object
- PythonObject @@? Thing -- whether a python object has an attribute
- `PythonObject ** PythonObject` -- see PythonObject ^ PythonObject -- exponentiation of Python objects
- `PythonObject ** Thing` -- see PythonObject ^ PythonObject -- exponentiation of Python objects
- PythonObject ^ PythonObject -- exponentiation of Python objects
- `PythonObject ^ Thing` -- see PythonObject ^ PythonObject -- exponentiation of Python objects
- `Thing ** PythonObject` -- see PythonObject ^ PythonObject -- exponentiation of Python objects
- `Thing ^ PythonObject` -- see PythonObject ^ PythonObject -- exponentiation of Python objects
- `PythonObject **= Thing` -- see PythonObject ^= Thing -- augmented exponentiation for Python objects
- PythonObject ^= Thing -- augmented exponentiation for Python objects
- PythonObject ^^ PythonObject -- bitwise exclusive disjunction of Python objects
- `PythonObject ^^ Thing` -- see PythonObject ^^ PythonObject -- bitwise exclusive disjunction of Python objects
- `Thing ^^ PythonObject` -- see PythonObject ^^ PythonObject -- bitwise exclusive disjunction of Python objects
- PythonObject ^^= Thing -- augmented bitwise exclusive disjunction of Python objects
- PythonObject _ Thing -- get elements of python sequences
- PythonObject _ Thing = Thing -- set elements of mutable python sequences
- PythonObject | PythonObject -- bitwise disjunction of Python objects
- `PythonObject | Thing` -- see PythonObject | PythonObject -- bitwise disjunction of Python objects
- `Thing | PythonObject` -- see PythonObject | PythonObject -- bitwise disjunction of Python objects
- PythonObject |= Thing -- augmented bitwise disjunction of Python objects
- PythonObject ~ -- bitwise negation of a python object
- PythonObject and PythonObject -- logical conjunction of Python objects
- `PythonObject and Thing` -- see PythonObject and PythonObject -- logical conjunction of Python objects
- `Thing and PythonObject` -- see PythonObject and PythonObject -- logical conjunction of Python objects
- PythonObject or PythonObject -- logical disjunction of Python objects
- `PythonObject or Thing` -- see PythonObject or PythonObject -- logical disjunction of Python objects
- `Thing or PythonObject` -- see PythonObject or PythonObject -- logical disjunction of Python objects
- PythonObject xor PythonObject -- logical exclusive disjunction of Python objects
- `PythonObject xor Thing` -- see PythonObject xor PythonObject -- logical exclusive disjunction of Python objects
- `Thing xor PythonObject` -- see PythonObject xor PythonObject -- logical exclusive disjunction of Python objects
- quotientRemainder(PythonObject,PythonObject) -- get the quotient and remainder when dividing Python objects
- `quotientRemainder(PythonObject,Thing)` -- see quotientRemainder(PythonObject,PythonObject) -- get the quotient and remainder when dividing Python objects
- `quotientRemainder(Thing,PythonObject)` -- see quotientRemainder(PythonObject,PythonObject) -- get the quotient and remainder when dividing Python objects
- remainder(PythonObject,PythonObject) -- remainder of python objects
- `remainder(PythonObject,Thing)` -- see remainder(PythonObject,PythonObject) -- remainder of python objects
- `remainder(Thing,PythonObject)` -- see remainder(PythonObject,PythonObject) -- remainder of python objects
- `round(PythonObject)` -- see round(PythonObject,PythonObject) -- round a python object
- round(PythonObject,PythonObject) -- round a python object
- `round(PythonObject,Thing)` -- see round(PythonObject,PythonObject) -- round a python object
- `round(Thing,PythonObject)` -- see round(PythonObject,PythonObject) -- round a python object
- sin(PythonObject) -- sine of a python object
- sinh(PythonObject) -- hyperbolic sine of a python object
- sqrt(PythonObject) -- square root of a python object
- tan(PythonObject) -- tangent of a python object
- tanh(PythonObject) -- hyperbolic tangent of a python object
- `describe(PythonObject)` -- see toExternalString(PythonObject) -- unambiguous string representation of a python object
- toExternalString(PythonObject) -- unambiguous string representation of a python object
- `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
- `expression(PythonObject)` -- see toString(PythonObject) -- readable string representation of a python object
- `net(PythonObject)` -- see toString(PythonObject) -- readable string representation of a python object
- `texMath(PythonObject)` -- see toString(PythonObject) -- readable string representation of a python object
- toString(PythonObject) -- readable string representation of a python object
- 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 /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Python/doc.m2:159:0.