On Wed, Oct 23, 2019 at 10:59 AM Steven D'Aprano
On Wed, Oct 23, 2019 at 10:09:41AM -0400, David Mertz wrote:
One big problem with the current obvious way would be shared by the proposal. This hits me fairly often.
colors1 = "red green blue".split() # happy
Later
colors2 = "cyan forest green burnt umber".split() # oops, not what I wanted, quote each separately
It isn't shared by the proposal.
colors2 = %w[cyan forest green burnt\x20umber]
Escaping the space ``\ `` might be nicer, but escaping an invisible character is problematic (see the problems with the explict line continuation character ``\``) and we may not be able to add any new escape characters to the language. However a hex escape will do the trick.
Compare that to: colors2 = "cyan,forest green,burnt umber".split(',') or, if you follow pep8-style commas: colors2 = "cyan, forest green, burnt umber".split(', ') This is one of the many cases where being able to specify the delimiter helps.