By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,441 Members | 1,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,441 IT Pros & Developers. It's quick & easy.

string/list comparison

P: n/a
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()

Jul 6 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.