re question

Amit Gupta emailamit at
Thu Feb 7 19:47:52 CET 2008

On Feb 7, 10:38 am, Amit Gupta <emaila... at> wrote:
> Python'ites
> I searched around "google" to find the answer to this question, but I
> can't:
> I have a named regexp : x = re.compile("(?P<me>[a-z]+)")
> What I want is an iterator, that can return me both the "groupname"
> and the matched string,  e.g:
> m ="aa")
> Somehow, I want to get
> {"me" : "aa"}, either as dictionary or some iterable form.
> All I found is, I need to know the "groupname" to get the
> corresponding match. Any help is appreciated.
> A

Got It. has a function groupdict(), doing precisely that.

More information about the Python-list mailing list