[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev
Ivo Shipkaliev added the comment: 2. (continued) .. This is including the case when both variables have the same internal name (the current implementation). -- ___ Python tracker

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread RhinosF1
Change by RhinosF1 : -- nosy: +RhinosF1 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev
Ivo Shipkaliev added the comment: There are 2 good reasons for making Tk variables comparable by value: 1. We honor the equality operator! The equality operator (==) has to compare two objects by value. The current implementation does not fulfil this. Yes, if two Tk variables have the

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Serhiy Storchaka
Serhiy Storchaka 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)

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev
Ivo Shipkaliev 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

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It will break existing code which depends on the current behavior. I don't see a problem with comparing variables by name. -- ___ Python tracker

[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev
New submission from Ivo Shipkaliev : Greetings! I just noticed: >>> import tkinter as tk >>> root = tk.Tk() >>> str_0 = tk.StringVar() >>> str_0.set("same value") >>> str_1 = tk.StringVar() >>> str_1.set("same value") So: >>> str_0.get() == str_1.get() True But: >>> str_0 == str_1 False