Serhiy Storchaka <[email protected]> added the comment:
> If the issue really boils down to incorrectly passing a single string when
> there is only one item in 'values', and a single-item tuple should be used
> instead, then shouldn't the better solution be for Python to handle this
> automatically and re-cast the errant string into a tuple?
Tkinter is rather a thin wrapper around Tcl/Tk. I just passes values to Tcl.
Tcl is a weak typed language. Internally it can use different types for
performance, but semantically all are strings. "a b" is a string and a
2-element list, and a 1-element dict at the same time. It is Tcl try to re-cast
the errant string into a Tcl list, and fails because it has incorrect syntax.
Python can't know your intention. It supposes that you know what you do. If
under re-casting you meant passing a string to a tuple constructor,
`tuple(values)`, this will be obviously wrong. If your meant parsing a string
to a tuple at Python side -- it will file as well as parsing it at Tcl side. If
you meant wrapping a string into a one-element tuple, `(values,)`, this can
break working code when a user intentionally passes a space separated list of
words:
tv.insert("", END, values=(foo, bar), tags="foo bar")
Additionally, any special cases will complicate the code of Tkinter (currently
it is rather a thin wrapper) and complicate the mental model.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32328>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com