Ivo Shipkaliev <ivo.shipkal...@gmail.com> added the comment:

If it's gonna break existing code -- fine. I just wanted to point out that if 
two variables are of the same type and refer to the same value, they should be 
considered equal, even if they are not the same variable.

In the current implementation, two StrVars can hold the same strings, but are 
compared unequal, which doesn't seem right.

Considering that we are going through the Tcl interpreter, equality should 
compare by value, not by identity (regardless of the variable names).

Look at this, please.

>>> int_0 = tk.IntVar()
>>> int_0.set(51)

>>> int_1 = tk.IntVar()
>>> int_1.set(51)


How can:

>>> int_0.get() == int_1.get()
True

and

>>> type(int_0) == type(int_1)
True

..but:

>>> int_0 == int_1
False

This means that the equality operator is only showing the difference in their 
names, and the statement above loses meaning, as it can never return True.

I think "int_0 is int_1" should be False as it is now. "is" should take into 
account their names as defined in the Tcl interpreter.

But "int_0 == int_1" should be True. Same as a couple of identical Python lists 
with different names.

Thank you!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42750>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to