Newbie question : string processing with RE

Patrick.Bussi at Patrick.Bussi at
Tue Mar 27 17:32:20 CEST 2001


I have difficulty with the search method of the re module, when applied to an
object retrieved from urllib.In the following program, f3 is read once and the
search is effective. But when I try to read it again, it acts as if the index of
a file had to be "rewinded" (e.g. as would do a "seek" on a "true" file). I
thought that was to be considered as a string. Could someone help me
understand my mistake and give me a nice solution (means not storing data into a

Thank you in advance.

 #! /usr/bin/env python
 # file test 22
 import re, socket, urllib
 encoded_data = ... # bla-bla-bla
 f3 = urllib.urlopen ("", encoded_data)
 q=re.compile("document.location =" )
 print p,'\n',q
 # ---- end of file test22 ----

 $ test22
 <re.RegexObject instance at 8135458>
 <re.RegexObject instance at 81354e0>
 Traceback (innermost last):
   File "./test22", line 12, in ?
 AttributeError: 'None' object has no attribute 'group'

Patrick Bussi
patrick.bussi at

Any opinions expressed are my own and not necessarily those of my Company.

More information about the Python-list mailing list