abc#

This module exports all latin and greek letters as Symbols, so you can conveniently do

>>> from sympy.abc import x, y

instead of the slightly more clunky-looking

>>> from sympy import symbols
>>> x, y = symbols('x y')

Caveats#

1. As of the time of writing this, the names O, S, I, N, E, and Q are colliding with names defined in SymPy. If you import them from both sympy.abc and sympy, the second import will “win”. This is an issue only for * imports, which should only be used for short-lived code such as interactive sessions and throwaway scripts that do not survive until the next SymPy upgrade, where sympy may contain a different set of names.

2. This module does not define symbol names on demand, i.e. from sympy.abc import foo will be reported as an error because sympy.abc does not contain the name foo. To get a symbol named foo, you still need to use Symbol('foo') or symbols('foo'). You can freely mix usage of sympy.abc and Symbol/symbols, though sticking with one and only one way to get the symbols does tend to make the code more readable.

The module also defines some special names to help detect which names clash with the default SymPy namespace.

_clash1 defines all the single letter variables that clash with SymPy objects; _clash2 defines the multi-letter clashing symbols; and _clash is the union of both. These can be passed for locals during sympification if one desires Symbols rather than the non-Symbol objects for those names.

Examples#

>>> from sympy import S
>>> from sympy.abc import _clash1, _clash2, _clash
>>> S("Q & C", locals=_clash1)
C & Q
>>> S('pi(x)', locals=_clash2)
pi(x)
>>> S('pi(C, Q)', locals=_clash)
pi(C, Q)