> If you can get by with a single literal list of words, write it once.
> ...if it's long enough to be annoying or becomes a maintenance burden,
use the `split()` idiom.
> ...if that's considered a "hack" or "bad form", then run it in the shell
once and copy/paste the result.
> ...if it might get mutated in a loop, copy it (words[:]). You'd be
constructing a new one anyways.
> ...if it's just too long to maintain in code, just load it from a txt
file once at runtime.

Well said, Brandt.

My personal preference is to run "...".split() in the shell and copy/paste
the output, as it takes an incredibly minimal amount of time to start up
the REPL for simple one liners. In my experience, folks often seem to
forget that the REPL (or IDLE shell) exists outside of demo examples; it's
highly useful for quick micro-scripts.

I'm not 100% opposed to the proposed functionality, but I'm against the
syntax and don't consider the lack of a shortcut to be particularly
detrimental in this case. IMO, anything that falls under the category of
being a syntactical shortcut should be highly readable and fairly obvious
as to what it's doing at a first glance. Otherwise, it adds an unnecessary
cost to the learning curve of Python (which can very rapidly accumulate if
it's not kept in check).


On Thu, Oct 24, 2019 at 12:39 PM Brandt Bucher <brandtbuc...@gmail.com>
wrote:

> This is getting a little ridiculous.
>
> If you can get by with a single literal list of words, write it once.
> ...if it's long enough to be annoying or becomes a maintenance burden, use
> the `split()` idiom.
> ...if that's considered a "hack" or "bad form", then run it in the shell
> once and copy/paste the result.
> ...if it might get mutated in a loop, copy it (words[:]). You'd be
> constructing a new one anyways.
> ...if it's just too long to maintain in code, just load it from a txt file
> once at runtime.
>
> These are simple engineering solutions to simple engineering problems. As
> a bonus, they don't require implementation maintainers to redesign their
> tokenizers/parsers or build a brand-new preprocesser.
>
> Python-ideas truly is a unique, wonderful, exhausting place. Back to the
> "plus/pipe" thread (formerly known as the "PEP 584" thread)...
> _______________________________________________
> 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/THBBTIQ34GYZSBW6PQXKKO3L3UADYBXB/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/ZRVXFZTTKBN4OUL4NLNNCLYM6GFUTI2J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to