[Tutor] re.findall vs. re.search and re.match

Max Noel maxnoel_fr at yahoo.fr
Tue Mar 15 18:09:50 CET 2005


On Mar 15, 2005, at 16:44, Ron Nixon wrote:

> Kent:
>
> The code is below. Here's the error message.
>
> Traceback (most recent call last):
>   File "C:/Python24/reformat.py", line 5, in
> -toplevel-
>     name = x.group(1)
> AttributeError: 'list' object has no attribute 'group'

	re.findall returns a list object (as the error message says). Use name 
= x[1] instead. (and be careful, numbering starts from 0, so this code 
may contain a Kenobi error).

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list