String comparison

Terry Reedy tjreedy at
Thu Aug 22 03:50:03 CEST 2002

> postReply = urllib.urlopen("",
>  print postReply

If this works, postReply *is* a string

>  f = open("D:\PythonServerMonitor\KWE1144589.dat","r")

Either change '\' to '/' (works fine on windows) or prepend 'r' to
as in r"D:......"

>  controlData =
>  f.close()

If this works, controlData *also* is a string.  Try

print controlData

>  if (str(postReply) == str(controlData)):       #Here is the

Python is not C.  You just need

if postReply == controlData:

> I've also tried...
>  if (strcmp(postReply, controlData) == 0):

strcmp() is C, not Python, so this should give NameError

Terry J. Reedy

More information about the Python-list mailing list