Re: Typed named groups in regular expression
- From: Steve Holden <steve@xxxxxxxxxxxxx>
- Date: Wed, 16 May 2007 16:07:36 -0400
Hugo Ferreira wrote:
Hi!
Is it possible to "automagically" coerce the named groups to python types? e.g.:
<type 'str'>type(re.match('(?P<x>\d*)', '123').groupdict()['x'])
But what I'm looking forward is for the type to be 'int'.
Cheers!
Hugo Ferreira
So apply the "int()" function to the str and it will be!
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
.
- Prev by Date: Re: Execute commands from file
- Next by Date: Re: PEP 3131: Supporting Non-ASCII Identifiers
- Previous by thread: Re: Typed named groups in regular expression
- Next by thread: Python-URL! - weekly Python news and links (May 16)
- Index(es):
Relevant Pages
|
|