Comment by thayne
2 days ago
I don't think this is necessarily a "crime", I could see this being useful.
An example that uses a similar approach would be if you had a metaclass that overrode __instancecheck__ to return true if a string matched a regular expression. Then you could create (dynamically defined) classes that used that metaclass to use in match statements to march a string against multiple regexes. Unfortunately, I can't think of a good way to extract any capture groups.
No comments yet
Contribute on Hacker News ↗