String comparison

David Iungerich david.iungerich at
Thu Aug 22 11:00:02 EDT 2002

There was some whitespace junk in the file.  The following works fine.

		postReply = urllib.urlopen("",

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

		print "     <ControlData>" + str(len(controlData)) + "</ControlData>"
		print "     <ServerData>" + str(len(postReply)) + "</ServerData>"

		if (postReply == controlData):
			response = "<ServerResponseTest>Response - OK</ServerResponseTest>"
			response = "<Result>Server Not Responding</Result>"
   		# e-mail appropriate party.

	except Exception:
		print Exception
		# e-mail the admin.

-----Original Message-----
From: python-list-admin at
[mailto:python-list-admin at]On Behalf Of Brian Jones
Sent: Thursday, August 22, 2002 3:57 AM
To: python-list at
Subject: Re: String comparison

> if s1.lower() == s2.lower():
>    blah()
> I suppose this would do the trick, too:
> if re.match( '^' + s1 + '$', s2, re.I ):
>    blah()
> I'm not sure which of these is better (or maybe it is neither!), though,
> of course, I'd like to know what the One True Path is...

As a real Python newbie making his first post here may I vote for the

For me one of Python's great strengths is that it does not carry the
baggage of C++ or Java, and avoids the obfuscation of Perl (and readily
available in C). It is clean and intrinsically simple.

The first of your choices bears the simplicity of Python whilst the
second reminds me of Perl.

Regexs are powerful when they are needed but why add complexity and
decrease readability where they are not needed.


More information about the Python-list mailing list