Top
Back: pyobject expressions
Forward: pyobject related functions
FastBack: polytope
FastForward: countedref
Up: pyobject
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.25.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;
pyobject three = 3;

two + three;
==> 5
two - three;
==> -1
two * three;
==> 6
two / three;
==> 0
two ^ three;
==> 8
two ** three;
==> 8

three < two;
==> 0
two < three;
==> 1
three <= two;
==> 0
two <= three;
==> 1
two == three;
==> 0
two == two;
==> 1
three > two;
==> 1
two > three;
==> 0
three >= two;
==> 1
two >= three;
==> 0
two != two;
==> 0
two != three;
==> 1

pyobject pystr = "Hello";
pystr + " World!";
==> 'Hello World!'
pystr * 3;
==> 'HelloHelloHello'
pystr[1];
==> 'e'

python_run("def newfunc(*args): return list(args)");
newfunc();
==> []
newfunc(two, three);
==> [2, 3]

newfunc."__class__";
==> <type 'function'>
newfunc::"__class__";
==> <type 'function'>
newfunc.func_name;
==> 'newfunc'
newfunc::func_name;
==> 'newfunc'


Top Back: pyobject expressions Forward: pyobject related functions FastBack: polytope FastForward: countedref Up: pyobject Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 4-0-3, 2016, generated by texi2html.