Serhiy Storchaka added the comment:
Tcl is weak typed language and all Tcl values formally are strings. "123" is
the 123 integer, the "123" string, and Tcl list containing one element "123"
(which can be a number, a string, a list, etc). Actually for optimization Tcl
uses different specialized types internally and Tkinter uses it for converting
Tcl values to Python values (when wantobject is true). When wantobject is
false, tkinter always returns string. If Tkinter encounters unknown to it Tcl
type, it returns Tcl_Obj. Tcl introduces new types in new versions and Tcl
function which returned string or Tcl list in old version can return new type
in new version.
So any Tkinter method which supposed return a "list", can return a tuple, a
string, or a Tcl_Obj.
splitlist() splits a string, a tuple or a Tcl_Obj to Python tuple.
'' -> ()
'abc' -> ('abc',)
'abc def' -> ('abc', 'def')
'abc {def ghi}' -> ('abc', 'def ghi')
It always returns a tuple (of strings if an argument is a string). If an
argument already is a tuple, splitlist() just returns it. If an argument is Tcl
list, splitlist() returns a tuple which contains it's elements.
split() is more intelligent. It try guess a structure of data and splits "list"
to subelements while it is possible.
'' -> ''
'abc' -> 'abc'
'abc def' -> ('abc', 'def')
'abc {def ghi}' -> ('abc', ('def', 'ghi'))
If an argument is a tuple, split() recursively splits it's elements. When an
argument is TclObj, split() returns a string if Tcl list has 0 or 1 element,
otherwise it returns the same value as splitlist().
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19020>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com