import vcsn
c = vcsn.context('lal_char, q')
e = c.expression('<2>a(b+<3>c)')
x = e.expansion()
x
x.lweight(c.weight('4'))
Instead of x.lweight(w)
, you may write w * x
.
c.weight('4') * x
You may even run the simpler:
4 * x
The expansion of a scalar product is the scalar product of the expansion:
(4*e).expansion()