string/list comparison

B

bruce

hi...

i have the following piece of code that i'm testing... it should be
using/comparing two equal strings. apparently it doesn't. i've tried to do a
"strip" to remove pre/post whitespace.. but there appears to be something
else going on.

i suspect that there is some type of unicode going on. is there some way
that i can print out what's really in the string so i can know what to
remove...

in the test, the sstr/trstr should both be "Summer A" for some reason i'm
getting a len of 10 and 11 chars...

any thoughts/comments...

thanks

-bruce

#extract process from the class page
print "section"
f = urllib.urlopen(url)
s = f.read()
f.close()
#print s
# s contains HTML not XML text
d = libxml2dom.parseString(s, html=1)

#get the tr list
tr1 = d.xpath(alltr)

#get the sess list
sess1 = d.xpath(sess)

#build the tr list
trlist = []
for aaa in tr1:
trlist.append(aaa.nodeValue)
#print "aaa = ",aaa.nodeValue

#build the course list
sesslist = []
for aaaa in sess1:
sesslist.append(aaaa.nodeValue)
#print "aaaa = ",aaaa.nodeValue


print "sesstest = ",sesslist[0]
print "sesstest2 = ",sesslist[1]
print "trtest = ",trlist[3]


sstr = sesslist[0] <<<<<<<<<<<<<<<<<< these should be the same
trstr = trlist[3] <<<<<<<<<<<<<<<<<< "Summer A"

sstr.strip(sstr)
trstr.strip(trstr)

print "slen = ",len(sstr)
print "trlen = ",len(trstr)

if sesslist[0] == trlist[3]:
print "okkkkkk"
sys.exit()
 

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,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top