String comparison

David Iungerich david.iungerich at
Thu Aug 22 22:08:38 CEST 2002

Will do.  Just forgot to mention it.  Thanks.

-----Original Message-----
From: python-list-admin at
[mailto:python-list-admin at]On Behalf Of Matt Gerrans
Sent: Thursday, August 22, 2002 2:28 PM
To: python-list at
Subject: Re: String comparison

> There was some whitespace junk in the file.  The following works fine.
> ...
> f = open("D:\PythonServerMonitor\KWE1144589.dat","r")

As Terry Reedy mentioned, you have unescaped backslashes in your filename,
but in this case, you are getting lucky, because neither '\P' nor '\K' are
escape seqences.   However, if any part of your path or file name started
with a character that is ('b', 'n', 't' and so on), you'd get an exception
every time.

To be safe, you should always use a raw string for the file name like so:
   f = open( r"D:\PythonServerMonitor\KWE1144589.dat", "r" )

or escape the backslashes like so:
   f = open( "D:\\PythonServerMonitor\\KWE1144589.dat", "r" )


More information about the Python-list mailing list