Monsieur AZERTY
Monsieur AZERTY

Reputation: 123

sympy how to compare symbol with list

I use sympy and i want compare a symbol with a list like that :

 >>> sympy.sympify("Eq(x,[])")

but that raise an error : sympy.core.sympify.SympifyError: SympifyError: []

however that works with set :

 >>> sympy.sympify("Eq(x,{})")
 Eq(x,{})

why that do not works with list and how to compare symbol with list ?

Upvotes: 0

Views: 98

Answers (1)

smichr
smichr

Reputation: 19029

It is a design goal of SymPy to not allow non-SymPy objects as arguments, so there is strong bias for this not to work. You can, however, use a tuple (which can be represented with Tuple as the argument:

>>> Eq(x, ())
Eq(x, ())
>>> _.subs(x, ())  # and _.subs(x, 1) -> False
True

Upvotes: 1

Related Questions