-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tkinter: deprecate the split() method #82552
Comments
The tkapp.split() method has weird behavior. It splits a string recursively, so the type of items and the depth of nesting depends on spaces in string values. For example: >>> import tkinter
>>> root = tkinter.Tcl()
>>> root.tk.split('Hi')
'Hi'
>>> root.tk.split('Hello "Good bye"')
('Hello', ('Good', 'bye')) It may work as you meant in some cases (if items at the same level either all have spaces or all do not have spaces), but return unexpected result for untested cases. It is more robust to use the tkapp.splitlist() method, which split exactly one level and always returns a tuple of strings. It can be used recursively if you need nested lists. >>> root.tk.splitlist('Hi')
('Hi',)
>>> root.tk.splitlist('Hello "Good bye"')
('Hello', 'Good bye')
>>> [root.tk.splitlist(x) for x in root.tk.splitlist('Hello "Good bye"')]
[('Hello',), ('Good', 'bye')] |
tkinter
split() method #28237Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: