2 ms·
I think it's a case where PEP 572 tries to fix bad library design. re.match shouldn't return None at all. I often write helper functions like: matcher = l
by est 8y ago
I think it's a case where PEP 572 tries to fix bad library design.
re.match shouldn't return None at all. I often write helper functions like:
matcher = lambda r, s: getattr(re.match(r, s), 'group', lambda i: '')
o = matcher(r1, s)(1) or matcher(r2, s)(3)
here matcher have a fixed, static return type, string.