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')
1. As of the time of writing this, the names
Q are colliding with names defined in SymPy. If you import them
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
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
you still need to use
You can freely mix usage of
sticking with one and only one way to get the symbols does tend to make the code
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
_clash2 defines the multi-letter clashing symbols;
_clash is the union of both. These can be passed for
during sympification if one desires Symbols rather than the non-Symbol
objects for those names.
>>> 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)