### 4.28.3 pyobject operations

`+`
  addition

`-`
  negation or subtraction

`*`
  multiplication

`/`
  division

`^`, `**`
  power by a positive integer

`<`, `<=`, `>`, `>=`, `==`, `<>`
  comparators (considering leading monomials w.r.t. monomial ordering)

pyobject_expression `[` int_expression `]`
  get the item from the pyobject by index
pyobject_expression `(` pyobject_expression_sequence `)`
  call the pyobject with a sequence of python arguments (the latter may be empty)

pyobject_expression `.` ( string_expression | name ),
  pyobject_expression `::` ( string_expression | name ) get attribute (class member) of a python object

Example:

    pyobject two = 2;
    ==> no pyobject support
    pyobject three = 3;

    two + three;
    ==>    ? `pyobject` + `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        4: `two + three;`
    two - three;
    ==>    ? `pyobject` - `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        5: `two - three;`
    two * three;
    ==>    ? `pyobject` * `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        6: `two * three;`
    two / three;
    ==>    ? `pyobject` / `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        7: `two / three;`
    two ^ three;
    ==>    ? `pyobject` ^ `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        8: `two ^ three;`
    two ** three;
    ==>    ? `pyobject` ^ `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        9: `two ** three;`

    three < two;
    ==>    ? `pyobject` < `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        11: `three < two;`
    two < three;
    ==>    ? `pyobject` < `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        12: `two < three;`
    three <= two;
    ==>    ? `pyobject` <= `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        13: `three <= two;`
    two <= three;
    ==>    ? `pyobject` <= `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        14: `two <= three;`
    two == three;
    ==>    ? `pyobject` == `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        15: `two == three;`
    two == two;
    ==>    ? `pyobject` == `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        16: `two == two;`
    three > two;
    ==>    ? `pyobject` > `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        17: `three > two;`
    two > three;
    ==>    ? `pyobject` > `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        18: `two > three;`
    three >= two;
    ==>    ? `pyobject` >= `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        19: `three >= two;`
    two >= three;
    ==>    ? `pyobject` >= `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        20: `two >= three;`
    two != two;
    ==>    ? `pyobject` <> `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        21: `two != two;`
    two != three;
    ==>    ? `pyobject` <> `pyobject` failed
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        22: `two != three;`

    pyobject pystr = "Hello";
    pystr + " World!";
    ==>    ? `pyobject` + `string` failed
    ==>    ? expected `string` + `string`
    ==>    ? expected `ring` + `string`
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        25: `pystr + " World!";`
    pystr * 3;
    ==>    ? `pyobject` * `int` failed
    ==>    ? expected `int` * `int`
    ==>    ? expected `matrix` * `int`
    ==>    ? expected `bigintmat` * `int`
    ==>    ? expected `bigintvec` * `int`
    ==>    ? expected `intvec` * `int`
    ==>    ? expected `intmat` * `int`
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        26: `pystr * 3;`
    pystr[1];
    ==>    ? `pyobject` [ `int` failed
    ==>    ? expected `intvec` [ `int`
    ==>    ? expected `bigintvec` [ `int`
    ==>    ? expected `ideal` [ `int`
    ==>    ? expected `map` [ `int`
    ==>    ? expected `module` [ `int`
    ==>    ? expected `string` [ `int`
    ==>    ? expected `list` [ `int`
    ==>    ? expected `poly` [ `int`
    ==>    ? expected `polyBucket` [ `int`
    ==>    ? expected `vector` [ `int`
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        27: `pystr[1];`

    python_run("def newfunc(*args): return list(args)");
    ==>    ? `python_run` is not defined
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        29: `python_run("def newfunc(*args): return list(args)");`
    newfunc();
    ==>    ? `newfunc` is not defined
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        30: `newfunc();`
    newfunc(two, three);
    ==>    ? `newfunc` undefined or  `int` expected while building `newfunc(`
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        31: `newfunc(two, three);`

    newfunc."__class__";
    ==>    ? `newfunc` is not defined
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        33: `newfunc."__class__";`
    newfunc::"__class__";
    ==>    ? 'newfunc' is an invalid package name
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        34: `newfunc::"__class__";`
    newfunc.func_name;
    ==>    ? `newfunc` is not defined
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        35: `newfunc.func_name;`
    newfunc::func_name;
    ==>    ? 'newfunc' is an invalid package name
    ==>    ? error occurred in or before ./examples/pyobject_operations.sing line\
        36: `newfunc::func_name;`

User manual for Singular version 4.4.1, 2025, generated by texi2html.