Manfred Weis
Manfred Weis

Reputation: 836

Constraints on argument to sympy.Symbol

I am looking for an official specification of the constraints on sympy's Symbol() function.

The use itself is not subject of this question

x = sympy.Symbol("whatever") associates the python variable x with the symbol whatever

I can however not find a specification of what qualifies as an argument to sympy.Symbol; out of curiosity and for later use in MathJax I entered

sympy.Symbol("\textcolor{red}{whatever}") In IDLE, which caused the program to hang, therefore my

Question:
in which freely online accessible documents are the constraints on sympy.Symbol formally defined.

searching online for quite a while I could only find examples, but no definitions

Upvotes: 0

Views: 94

Answers (1)

Oscar Benjamin
Oscar Benjamin

Reputation: 14480

The docs are somewhat light on detail: https://docs.sympy.org/latest/modules/core.html#module-sympy.core.symbol

I think that any string should be valid though. I'm not sure about the problem you had with IDLE. In isympy that works fine:

In [5]: Symbol("\\textcolor{red}{whatever}")                                                                                                                                      
Out[5]: \textcolor{red}{whatever}

Upvotes: 1

Related Questions