On 9/17/2020 6:56 PM, Chris Angelico wrote:
On Fri, Sep 18, 2020 at 8:54 AM Ben Rudiak-Gould <benrudiak@gmail.com> wrote:
This is a terrible idea.
No one should ever be trying to extract data from strings that are obviously meant for human consumption, like "It is 11:45 PM".
I'll grant you that it's sometimes necessary. But it needs to be approached very carefully. You need to use a --porcelain flag if available, you need to check that the actual output format matches what you expect, and you definitely need to be able to specify where substring matching stops in more ways than "int or float or string".
The last thing Python needs is a built-in language feature that makes hacking together these sorts of parsers seem easy and fun. Especially when it has no way to control backtracking or to specify any but a few trivial restrictions on what can end up in the output variables.
Python is an excellent language for text manipulation, and text manipulation is an incredibly useful real-world operation. I don't see what you're complaining at.
ChrisA I don't either. This could be incredibly useful for simple string extraction. Obviously, there are situations where regex is a much better option, but why object to a simple option for simple problems?
--Edwin