This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author shippo_
Recipients epaine, serhiy.storchaka, shippo_
Date 2020-12-26.18:01:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609005716.4.0.471939581858.issue42750@roundup.psfhosted.org>
In-reply-to
Content
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!
History
Date User Action Args
2020-12-26 18:01:56shippo_setrecipients: + shippo_, serhiy.storchaka, epaine
2020-12-26 18:01:56shippo_setmessageid: <1609005716.4.0.471939581858.issue42750@roundup.psfhosted.org>
2020-12-26 18:01:56shippo_linkissue42750 messages
2020-12-26 18:01:56shippo_create