def __mul__(self, other):
        """\
>>> str(SimplePolynomial() * 2)
'2*X'
>>> str(2 * SimplePolynomial())
'2*X'
>>> str(SimplePolynomial() * SimplePolynomial())
'X**2'
"""
        if isinstance(other, Number):
            return SimplePolynomial([c * other for c in self.terms])
        terms = [0]*(len(self.terms)+len(other.terms))
        for i1, c1 in enumerate(self.terms):
            for i2, c2 in enumerate(other.terms):
                terms[i1+i2] += c1*c2
        return SimplePolynomial(terms)
>>> str(SimplePolynomial() * 2)
'2*X'
>>> str(2 * SimplePolynomial())
'2*X'
>>> str(SimplePolynomial() * SimplePolynomial())
'X**2'

recipes/Python/576953_Simple_polynomial_class/recipe-576953.py