On 10/23/19 6:07 AM, Ricky Teachey wrote:

    I would expect %w{ ... } to return a set, not a list:

         %w[ ... ]  # list
         %w{ ... ]  # set
         %w( ... )  # tuple

    and I would describe them as list/set/tuple "word literals". Unlike
    list etc displays [spam, eggs, cheese] these would actually be true
    literals that can be determined entirely at compile-time.

A more convenient way to populate lists/tuples/sets full of strings at compile time seems like a win.

If I might be allowed to bikeshed: the w seems unnecessary. Why not drop it in favor of a single character like %, and use an optional r for raw strings?

     %[words]  # "words".split()
     %{words}  # set("words".split())
     %(words)  # tuple("words".split())
     %r[wo\rds]  # "wo\\rds".split()
     %r{wo\rds}  # set("wo\\rds".split())
     %r(wo\rds)  # tuple("wo\\rds".split())

At that point, the "obvious" choice is an "s" (short for "split")
string rather than a whole new construct:

    >>> s"one two three"
    ["one", "two", "three"]

which could be combined with "r" like f and b strings.
_______________________________________________
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/PN4CSBEU6GFNT37HBRU325F6BDRPWR7N/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to