Typed named groups in regular expression

Hugo Ferreira bytter at gmail.com
Wed May 16 13:58:44 EDT 2007


Hi!

Is it possible to "automagically" coerce the named groups to python types? e.g.:

>>> type(re.match('(?P<x>\d*)', '123').groupdict()['x'])
<type 'str'>

But what I'm looking forward is for the type to be 'int'.

Cheers!

Hugo Ferreira



More information about the Python-list mailing list