String comparison

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


Will do.  Just forgot to mention it.  Thanks.

-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Matt Gerrans
Sent: Thursday, August 22, 2002 2:28 PM
To: python-list at python.org
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" )



-- 
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list