htmldata and python 2.2

T

Tim Arnold

I'm trying to get htmldata.py (written with Python 2.3 in mind) to work with
Python 2.2. Thanks much to Paul Clinch for showing me how to convert
for i, text in enumerate(L)
to
for i, text in zip(range(len(L)),L)

I have one more glitch in getting htmldata.py to work in Python2.2:
Can someone show me how to recode this without the finditer?

L = list(re.finditer(r'url\s*\(([^\r\n\("]*?)\)|' +
r'url\s*\(\s*"([^\r\n]*?)"\s*\)', doc))

The doc says re.finditer is available in 2.2, but I'm guessing it must be
in a minor version update (e.g., 2.2.3). Anyway, I'm getting this error in
the Traceback:

L = list(re.finditer(r'url\s*\(([^\r\n\("]*?)\)|' +
AttributeError: 'module' object has no attribute 'finditer'

thanks,
--Tim Arnold

p.s. htmldata.py is public domain code to manipulate
HTML or XHTML documents from Connelly Barnes.
(http://oregonstate.edu/~barnesc/htmldata/)
 
J

Just

"Tim Arnold said:
I'm trying to get htmldata.py (written with Python 2.3 in mind) to work with
Python 2.2. Thanks much to Paul Clinch for showing me how to convert
for i, text in enumerate(L)
to
for i, text in zip(range(len(L)),L)

I have one more glitch in getting htmldata.py to work in Python2.2:
Can someone show me how to recode this without the finditer?

L = list(re.finditer(r'url\s*\(([^\r\n\("]*?)\)|' +
r'url\s*\(\s*"([^\r\n]*?)"\s*\)', doc))

The doc says re.finditer is available in 2.2, but I'm guessing it must be
in a minor version update (e.g., 2.2.3). Anyway, I'm getting this error in
the Traceback:

L = list(re.finditer(r'url\s*\(([^\r\n\("]*?)\)|' +
AttributeError: 'module' object has no attribute 'finditer'

Seems you're hitting http://python.org/sf/585882, a bug that was fixed
in 2.2.2. You could use re.findall() instead.

Just
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top