klappnase <klappn...@web.de> added the comment:

The behavior of Tkinter when handling boolean values appears to be a bit 
erratic at times, not only BooleanVar.get() returns 0/1 instead of True/False 
(e.g. see the thread at tkinter-discuss: 
http://mail.python.org/pipermail/tkinter-discuss/2012-June/003176.html ). This 
is apparently because tk itself uses the strings '0' and '1' as boolean values, 
so behind the scenes Tkinter has to convert any bool into a string when setting 
a value and the string back into a bool when retrieving it, and it seems like 
most of the Tkinter code (and docstrings) was written in the good ol' days when 
Python used 0 / 1 itself.
Now when it comes to change Tkinter's behavior I'd tend to be careful. For 
example BooleanVar.get() could easily be changed to always return True/False. 
But imho this change would only make sense if you add strict input value 
checking for set() either, otherwise we just change one incoherency with 
another. But this would mean that we might end up breaking a lot of working 
code, for what seems to me a primarily aesthetic reason.

And of course, I don't see much use in isolated changes of the behavior of one 
function here and another method there. I feel that if the behavior of Tkinter 
concerning bool values was to be changed, there should at least be a thorough 
change of *any* Tkinter method that gets / sets boolean values so we at least 
end up with an overall coherent solution.
But again, this looks like quite a lot of work, will break running code and add 
no significant benefit besides a cosmetic improvement.
So my vote goes to accepting that 0 and 1 are ok boolean values in Tkinter and 
changing no more than misleading docstrings, as in this example of 
BooleanVar.get():

    def get(self):
        """Return the value of the variable as 1 (True) or 0 (False)."""
        return self._tk.getboolean(self._tk.globalgetvar(self._name))

----------
nosy: +klappnase

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

Reply via email to