> 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())
_______________________________________________ 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/LZK45BJ5WGSOQ5PVLMV6YTWBW376RIJ4/ Code of Conduct: http://python.org/psf/codeofconduct/