This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients bsherwood, ezio.melotti, gpolo, serhiy.storchaka, terry.reedy, vstinner
Date 2013-10-02.18:44:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380739462.89.0.894384802612.issue19020@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2013-10-02 18:44:22serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, bsherwood, vstinner, gpolo, ezio.melotti
2013-10-02 18:44:22serhiy.storchakasetmessageid: <1380739462.89.0.894384802612.issue19020@psf.upfronthosting.co.za>
2013-10-02 18:44:22serhiy.storchakalinkissue19020 messages
2013-10-02 18:44:22serhiy.storchakacreate