Yes, this is intentional. It is really no different than this: In [1]: a = 1
In [2]: b = 1 In [3]: type(a) Out[3]: int In [4]: type(b) Out[4]: int In [5]: a == b Out[5]: True In [6]: a is b Out[6]: True Jason moorepants.info +01 530-601-9791 On Wed, Jun 3, 2020 at 12:53 PM James Bateman <james.bate...@gmail.com> wrote: > I've just discovered a bug in my code which boiled down to the following, > where a symbol "y" was given the same SymPy name as an existing symbol. > > import sympy as sp > x = sp.Symbol('x') > y = sp.Symbol('y') > > x == y # True > x is y # True; expected False > x + y # 2*x; expected x + x (which would have made the bug in my code more > apparent) > > The behaviour here is very surprising to me. I would have expected x and > y to be different Python objects with __repr__ methods which just so happen > to return the same string. Instead, x and y are apparently different > Python names for the same object (x is y). > > Is this intentional? I think I must misunderstand some deep design choice > in SymPy, and I can't express my confusion well enough to Google it. > Please help! > > > -- > 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 sympy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/f0084d3b-db98-43cb-becd-020a368aec87%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/f0084d3b-db98-43cb-becd-020a368aec87%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AgYSRWuJUMBrDKZdoq-TXoQL0%3DVtjhahp1aPvEJD9UX%3DA%40mail.gmail.com.