def __add__(self, other):
        """\
>>> str(SimplePolynomial() + 1)
'X + 1'
>>> str(1 + SimplePolynomial())
'X + 1'
>>> str(SimplePolynomial() + SimplePolynomial())
'2*X'
"""
        if len(self.terms) == 0:
            return other
        if isinstance(other, Number):
            terms = self.terms[:]
            terms[0] += other
            return SimplePolynomial(terms)
        return SimplePolynomial([
            add(*pair)
            for pair in izip_longest(self.terms, other.terms, fillvalue=0)
            ])
>>> str(SimplePolynomial() + 1)
'X + 1'
>>> str(1 + SimplePolynomial())
'X + 1'
>>> str(SimplePolynomial() + SimplePolynomial())
'2*X'

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