Ask Your Question

Revision history [back]

When defining MyRing, you could have:

class MyRing(Ring):

    Element = MyRingElement # usually the element class name doesn't end with an "s"

    def __init__(...):

or have the entire class MyRingElement called "Element" and nested in the ring class:

class MyRing(Ring):

    def __init__(self, ...):
        ...

    def other_methods(self, ...):

    class Element(SageObect):

        def __init__(self, ...):
            ...

Look at the source code for examples: sage.algebras.free_algebra, sage.algebras.steenrod.steenrod_algebra, sage.algebras.iwahori_hecke_algebra, and I'm sure also in sage.rings and in sage.categories.examples.