On May 16, 6:58 pm, "Hugo Ferreira" <[EMAIL PROTECTED]> wrote:
> 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

If you do a ot of that sort of thing in many programs
then it might be worth your while to set up a framework
that does it. Something like adding an underscore
then the name of a type conversion function to all
group names, and creating a function to apply the
type convertion function to all named groups of a
match object.
- Paddy.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to