Functions with leading and trailing double underscores __XXX__
are all predefined by Python. Functions with leading and trailing
single underscores _XXX_
are defined for Sage. Functions with a
single leading underscore are meant to be semi-private, and ones with
a double leading underscore are considered really private. Users can
create functions with leading and trailing underscores.
Just as Python has many standard special methods for objects, Sage
also has special methods. They are typically of the form
_XXX_
. (In a few cases the trailing underscore is not
included, but this will be changed so that the trailing underscore is
always included.) This section describes all special methods.
All objects in Sage should derive from the Cython extension
class SageObject
:
from sage.ext.sage_object import SageObject class MyClass(SageObject,...): ...
You should implement the _latex_
and _repr_
method
for every object. The other methods depend on the nature of the
object.