[Python-ideas] Python 2's re module should take longs
Terry Reedy
tjreedy at udel.edu
Tue Sep 30 21:31:59 CEST 2014
On 9/30/2014 1:16 PM, Ryan Gonzalez wrote:
> This works:
>
> re.search('(abc)', 'abc').group(1)
>
> but this doesn't:
>
> re.search('(abc)', 'abc').group(1L)
>
> The latter raises "IndexError: no such group". Shouldn't that
> technically work?
If groups were stored in a list, then technically, yes, not if groups
are stored in a dict to support named groups with just one structure.
Since the number of groups is limited to 99 or 100 in 2.7 (just changed
for 3.5), there is no technical reason to use longs.
Even if the exception were considered a bug, I would not change it since
using longs would restrict code to 2.7.9+ and make it less portable to 3.x.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list