Hi,
On 29 October 2013 17:26, Taylan Şengül <[email protected]> wrote:
> I want to check if the result of an expression is in a set:
>
>>>> from sympy import *
>>>> var('a')
> a
>>>> print(a-a in {0})
> False
>>>> print(a - a == 0)
> True
>
> How can I make the first statement True?
In [1]: var('a')
Out[1]: a
In [2]: a - a in set([0])
Out[2]: False
In [3]: a - a in set([S.Zero])
Out[3]: True
In [4]: a - a in sympify(set([0]))
Out[4]: True
In [5]: set([0, S.Zero])
Out[5]: set([0, 0])
In [6]: 0 == S.Zero
Out[6]: True
In [7]: hash(0) == hash(S.Zero)
Out[7]: False
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
Mateusz
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.