- @classmethod
- def fromsympy(cls, expr):
- import sympy
- if isinstance(expr, sympy.Dummy):
- return Dummy(expr.name)
- elif isinstance(expr, sympy.Symbol):
- return Symbol(expr.name)
- else:
- raise TypeError('expr must be a sympy.Symbol instance')
+
+def symbols(names):
+ """
+ This function returns a tuple of symbols whose names are taken from a comma
+ or whitespace delimited string, or a sequence of strings. It is useful to
+ define several symbols at once.
+
+ >>> x, y = symbols('x y')
+ >>> x, y = symbols('x, y')
+ >>> x, y = symbols(['x', 'y'])
+ """
+ if isinstance(names, str):
+ names = names.replace(',', ' ').split()
+ return tuple(Symbol(name) for name in names)