goodmami / pe

Fastest general-purpose parsing library for Python with a familiar API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rename pos to start in Match objects

goodmami opened this issue · comments

The pos attribute on re.Match objects is not the start of a match but the position in the string where the matching started. With re.match() this is the same, but it can be different with re.search().

Since pe is modeled on re, this difference would be confusing. To use the same API would require Match.start() and Match.end() methods. This is fine, but currently there's no way to get the start and end of specific groups. So perhaps just changing pos to a start attrribute (as end currently is) is sufficient. However it's possible that a later version could allow one to get the start and end of specific subexpressions (perhaps with the memo?) so using methods now would reduce the need to break the API later.