[issue42750] tkinter.Variable equality consistency

Serhiy Storchaka report at bugs.python.org
Sat Dec 26 13:31:56 EST 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

a = tk.IntVar(name='a')
b = tk.IntVar(name='a')
assert a == b  # they refers to the same variable
assert a is not b  # but they are different objects
a.set(42); assert b.get() == a.get() == 42  # yes, it is the same variable
c = tk.IntVar(name='c', value=42)
assert c != a  # they are different variables
assert c.get() == a.get() == 42  # although having equal values
a.set(43); assert c.get() != a.get() == 43  # and setting one does not affect other

I do not see good reasons for making Tk variables comparable by value instead of name.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42750>
_______________________________________


More information about the Python-bugs-list mailing list