5 ms·
If you are lexing there is a much better way than trying to munge together a giant regex manually: https://github.com/python/cpython/blob/3.4/Lib/re.py#L346 ht
by justin_vanw 11y ago
If you are lexing there is a much better way than trying to munge together a giant regex manually:
https://github.com/python/cpython/blob/3.4/Lib/re.py#L346 https://github.com/python/cpython/blob/3.4/Lib/re.py#L346
- DasIch 11y agoNo, using a completely undocumented class that heavily relies on further undocumented parts of the standard library that might be implementation details of the regex implementation is much better.
- justin_vanw 11y agoIt's been there for like 10 years, I think you'll be ok if you use it... If it goes away, you can just bring it back right?
- DasIch 11y agoIt'll stay but it's still undocumented and the code heavily relies on things that are undocumented as well. This makes understanding it unnecessarily difficult and forces you to comment your own code quite extensively. On the other hand you can easily generate a regular expression by doing a little bit of trivial string manipulation everyone is going to understand.
- justin_vanw 11y agoSo take the 'undocumented' code, copy it, paste it into a file, put the license comment at the top, and move on with your life. String munging regexes together is going to be slower and error prone.