Problem with REGEX in Python
Steven Taschuk
staschuk at telusplanet.net
Fri May 30 17:35:33 EDT 2003
Quoth Peter Abel:
[...]
> > "Martin P" <martin_p at despam.com> writes:
> >
> > > p = re.compile('.*[pP][ython].*')
> > > f=file("aufgabe14.test")
> **Here f is a filepointer**
>
> > > for currentline in f:
> **So this code can't work, because you can't iterate over a filepointer
Sure you can.
$ cat foo.py
# foo.py
for line in file('foo.py'):
print line,
$ python foo.py
# foo.py
for line in file('foo.py'):
print line,
Since Python 2.2, if memory serves.
[...]
--
Steven Taschuk staschuk at telusplanet.net
"Our analysis begins with two outrageous benchmarks."
-- "Implementation strategies for continuations", Clinger et al.
More information about the Python-list
mailing list