[Python-ideas] Match statement brainstorm

Paul Moore p.f.moore at gmail.com
Thu May 26 17:49:52 EDT 2016


On 26 May 2016 at 22:39, Sven R. Kunze <srkunze at mail.de> wrote:
> However, the absence of it forces people to invent other more flexible
> mechanisms and I'd actually like it this way.

For a bigger project maybe. If I were writing a proper parser for my
file, I wouldn't have done it like I did. But this was a relatively
quick, essentially one-off, data extraction task (that's what I do 99%
of the time) and for that, simple solutions are much more appropriate.

If I had a matching statement in my toolkit, I would have used it. If
I had a matching *library* I would have used it. (But not regex, it's
too messy for this particular task). But I wouldn't build my own "more
flexible" mechanism - my job today was to get the data out, not to
write reusable (or even long-term maintainable, if I'm honest!) code.

This does make one good point though - if this sort of matching could
be provided with a library, that would be just as viable an option for
my use case. But I've not seen such a library yet.

Paul


More information about the Python-ideas mailing list