I don't see what's wrong with `["one", "two", "three"]`. It's the most explicit 
and from the compiler perspective it's probably also as optimal as it can get. 
Also it doesn't hurt readability. Actually it helps. With syntax highlighting 
the word boundaries immediately become clear.

If you're having long lists of string literals and you're annoyed by having to 
type `"` and `,` for every element, then it is the job of your IDE to properly 
support you while coding, not the job of the syntax (as long as it's clear and 
concise).

For that reason all the advanced IDEs with all their features exists. Without 
code completion for example you could also ask for new syntax that helps you 
abbreviating long variable names, because it's too much to type. So instead of 
writing `this_is_a_very_long_but_expressive_name` you could do `this_is...` in 
case there's only one name that starts with "this_is" which can be resolved 
from your scope. That would even shorten the code. Nevertheless I think that 
code completion is a good idea and that we have to use the exact same name 
every time.

The same applies to these "word literals". If you need a list of words, you can 
already create a list literal with the words inside. If that's too much typing, 
then you should ask your favorite IDE to implement corresponding refactoring 
assistance. I'm pretty sure the guys at PyCharm would consider adding something 
like this (e.g. if the caret is inside a string literal you can access the 
context menu via <alt>+<enter> and there could be something like "split words").

Steve Jorgensen wrote:
> See 
> https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#The_%_Notatio...
> for what Ruby offers.
> For me, the arrays are the most useful aspect.
> %w{one two three}
> => ["one", "two", "three"]
> 
> I did a search, and I don't see that this has been suggested before, but I 
> might have
> missed something. I'm guessing I'm not the first person to ask whether this 
> seems like a
> desirable feature to add to Python.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/J7X7BGBNZY43NANEB5OLJXCQFMZ7KHJH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to