You can do this: class MyElement(Element): def is_regular(self): from sage.my_parent import MyParent P = MyParent()
That way you don't import MyParent when you import the element, only when you run the is_regular() method. Alternatively, the parent could have an is_regular(x) method and in the element you just call self.parent().is_regular(self). On Friday, November 9, 2012 2:36:23 PM UTC-5, Charles Bouillaguet wrote: > > On Nov 9, 2012, at 7:57 PM, Volker Braun wrote: > > > If you use the > > > > class MyParent(Parent) > > Element = MyElement > > > > syntax then you have to import MyElement. So you shouldn't import > MyParent in your element code or you will create a cyclic import (=bad). > > > > Are you sure that you need to create new parents from the element? Your > element should only work with the parent that it is an element of. New > Parents are generally constructed by coercion, but the coercion code lives > in MyParent. > > It's a bit more complicated than that… The setting is that if R is a > (multivariate) polynomial ring, and I is an ideal of R, then checking that > elements of the quotient R/I are regular requires working with a new > polynomial ring R', which is essentially a copy of R with one more > variable. > > So, sage.rings.QuotientRingElement needs to create instances of > multivariate polynomial rings. > > > If all fails you can still do a method-level import. But its likely that > you should not. > > Sorry for not being very familiar with python, but could you elaborate a > little? > > Thanks, > Charles > > > > > > > > > > > On Friday, November 9, 2012 1:13:20 PM UTC-5, Charles Bouillaguet wrote: > > Hi, > > > > Why does adding : > > > > from sage.rings.polynomial.polynomial_ring_constructor import > PolynomialRing > > > > at the beginning of quotient_ring_element.py create the weird error: > > > > Traceback (most recent call last): > > … > > AttributeError: 'module' object has no attribute 'quotient_ring' > > > > Is there a circular dependency problem? If so, how can I possibly create > polynomial rings inside quotient_ring_element ??? > > > > Cheers, > > ---- > > Charles Bouillaguet > > http://www.lifl.fr/~bouillaguet/ > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To post to this group, send email to > > sage-...@googlegroups.com<javascript:>. > > > To unsubscribe from this group, send email to > sage-devel+...@googlegroups.com <javascript:>. > > Visit this group at http://groups.google.com/group/sage-devel?hl=en. > > > > > > > > --- > Charles Bouillaguet > http://www.lifl.fr/~bouillaguet/ > > > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To post to this group, send email to sage-devel@googlegroups.com. To unsubscribe from this group, send email to sage-devel+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en.