Ask Your Question

Revision history [back]

There seems to be room for improvement in the design here. Basis elements apparently have the same parent as ordinary elements, and a.monomials() returns them as such, which makes it hard to get at the underlying tree.

From the source code, accessed by a??, we find that we can access the actual monomial by e.g.:

sage: a_tree = a.list()[0][0]; a_tree
[[x0, x1], x1]
sage: isinstance(a_tree, sage.algebras.lie_algebras.lie_algebra_element.LyndonBracket)
True
sage: a_tree._left
[x0, x1]
sage: a_tree._right
x1

You may want to discuss this on sage-devel.