Ask Your Question

Revision history [back]

Sage provides some functions with the same names as some Python built-in functions.

In the case of sum it tries to be unobtrusive, as @Emmanuel Charpentier's answer explains.

To force the use of Python's sum:

sage: from builtins import sum as python_sum
sage: python_sum([3, 4, 5])
12

To check where the currently active sum is from:

sage: import_statements(sum)
from sage.misc.functional import symbolic_sum

To have sum be Python's and symbolic_sum be Sage's:

sage: from builtins import sum
sage: from sage.misc.functional import symbolic_sum

To use symbolic_sum as sage_sum:

sage: from sage.misc.functional import symbolic_sum as sage_sum

Sage provides some functions with the same names as some Python built-in functions.

In the case of sum it tries to be unobtrusive, as @Emmanuel Charpentier's answer explains.

To force the use of Python's sum:

sage: from builtins import sum as python_sum
sage: python_sum([3, 4, 5])
12

To check where the currently active sum is from:

sage: import_statements(sum)
from sage.misc.functional import symbolic_sum

To have sum be Python's and symbolic_sum be Sage's:

sage: from builtins import sum
sage: from sage.misc.functional import symbolic_sum

To use symbolic_sum as sage_sum:

sage: from sage.misc.functional import symbolic_sum as sage_sum

The documentation could be improved on this topic. See the dedicated ticket: