Re: Typed named groups in regular expression

2007-05-20 Thread Paddy
On May 20, 2:27 am, Hugo Ferreira [EMAIL PROTECTED] wrote: Both Paddy (hackish) and McGuire (right tool for the job) ideas sound very interesting ;-) I'll definitely research on them further. Thanks for the support... Hackis, hackISH! Sir, I would have you know that the idea proffered is a

Re: Typed named groups in regular expression

2007-05-19 Thread Paul McGuire
On May 19, 12:32 am, Paddy [EMAIL PROTECTED] wrote: 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('(?Px\d*)', '123').groupdict()['x']) type 'str' But what I'm looking

Re: Typed named groups in regular expression

2007-05-19 Thread Hugo Ferreira
Both Paddy (hackish) and McGuire (right tool for the job) ideas sound very interesting ;-) I'll definitely research on them further. Thanks for the support... On 19 May 2007 04:39:58 -0700, Paul McGuire [EMAIL PROTECTED] wrote: On May 19, 12:32 am, Paddy [EMAIL PROTECTED] wrote: On May 16,

Re: Typed named groups in regular expression

2007-05-18 Thread Paddy
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('(?Px\d*)', '123').groupdict()['x']) type 'str' But what I'm looking forward is for the type to be 'int'. Cheers! Hugo

Typed named groups in regular expression

2007-05-16 Thread Hugo Ferreira
Hi! Is it possible to automagically coerce the named groups to python types? e.g.: type(re.match('(?Px\d*)', '123').groupdict()['x']) type 'str' But what I'm looking forward is for the type to be 'int'. Cheers! Hugo Ferreira -- http://mail.python.org/mailman/listinfo/python-list

Re: Typed named groups in regular expression

2007-05-16 Thread Steve Holden
Hugo Ferreira wrote: Hi! Is it possible to automagically coerce the named groups to python types? e.g.: type(re.match('(?Px\d*)', '123').groupdict()['x']) type 'str' But what I'm looking forward is for the type to be 'int'. Cheers! Hugo Ferreira So apply the int() function to

Re: Typed named groups in regular expression

2007-05-16 Thread Miki
Hello Hugo, Is it possible to automagically coerce the named groups to python types? e.g.: Not that I know of, however I use the following idiom: match = my_regexp.find(some_string) def t(name, convert=str): return convert(match.group(name)) myint = t(field1, int) HTH, -- Miki [EMAIL