Hi Volker, > I agree that I need to set the attribute Element not element_class in my > path. I'll fix it after the dust in #10496 has settled. > > I'm still confused about _element_class(). If you need to compute the > correct value of Element, then just do that in the constructor. So if > _element_class() is only called in the constructor then I'm perfectly happy > with that. But none of the derived classes of FGP_Module actually does that. > And before I rewrote things, it was full of "return > self.element_class()(V,W,check)" whenever an element was to be constructed. > > So my understanding is that parents should: > > * directly define myparent.Element if its always the same class > * define myparent.Element in myparent.__init__() if it depends on the > parent. > > Is that correct?
Just to make it clear: element_class is obtained by sub-classing Element adding all the class provided by the category system at the top of the mro. In principle, you should not touch it unless you want to reuse a already computed element class from a different parent in the same category. you can define myparent.Element in any way that suits you including 1 - as a class attribute: class myParent(...): ... class Element(...): ... or class myParent(...): ... Element = SomeClass 2 - as a lazy attribute class myParent(...): ... @lazy_attribute() def Element(self, ...): class Toto(...) ... return Toto 3 - as a standard attribute: class myParent(...): def __init__(self, ...): self.Element = ... Parent.__init__(self, ...) But in any way (and in particular for 3-) you have to define it *before* calling the initialization of category in Parent.__init__. Hope this helps, Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org