@@ -277,16 +277,40 @@ cdef class Element(sage_object.SageObject):
277
277
278
278
def __getattr__ (self , str name ):
279
279
"""
280
- Let cat be the category of the parent of ``self``. This
281
- method emulates ``self`` being an instance of both ``Element``
282
- and ``cat.element_class``, in that order, for attribute
283
- lookup.
280
+ Lookup a method or attribute from the category abstract classes.
284
281
285
- NOTE:
282
+ Let ``P`` be a parent in a category ``C``. Usually the methods
283
+ of ``C.element_class`` are made directly available to elements
284
+ of ``P`` via standard class inheritance. This is not the case
285
+ any more if the elements of ``P`` are instances of an
286
+ extension type. See :class:`Category`. for details.
287
+
288
+ The purpose of this method is to emulate this inheritance: for
289
+ ``e`` and element of ``P``, if an attribute or method
290
+ ``e.foo`` is not found in the super classes of ``e``, it's
291
+ looked up manually in ``C.element_class`` and bound to ``e``.
292
+
293
+ .. NOTES::
294
+
295
+ - Attributes beginning with two underscores but not ending
296
+ with an unnderscore are considered private and are thus
297
+ exempted from the lookup in ``cat.element_class``.
286
298
287
- Attributes beginning with two underscores but not ending with
288
- an unnderscore are considered private and are thus exempted
289
- from the lookup in ``cat.element_class``.
299
+ - The attribute or method is actually looked up in
300
+ ``P._abstract_element_class``. In most cases this is
301
+ just an alias for ``C.element_class``, but some parents,
302
+ notably homsets, customizes this to let elements also
303
+ inherit from other abstract classes. See
304
+ :meth:`Parent._abstract_element_class` and
305
+ :meth:`Homset._abstract_element_class` for details.
306
+
307
+ - This mechanism may also enter into action when the
308
+ category of `P` is refined on the fly, leaving
309
+ previously constructed elements in an outdated element
310
+ class.
311
+
312
+ See :class:`~sage.rings.polynomial.polynomial_quotient_ring.PolynomialQuotientRing_generic`
313
+ for an example.
290
314
291
315
EXAMPLES:
292
316
@@ -330,7 +354,6 @@ cdef class Element(sage_object.SageObject):
330
354
Traceback (most recent call last):
331
355
...
332
356
AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute '__foo'
333
-
334
357
"""
335
358
if (name.startswith(' __' ) and not name.endswith(' _' )):
336
359
dummy_error_message.cls = type (self )
0 commit comments