[Tutor] Python open of c:\ path Problem

Todd Zullinger tmz at pobox.com
Sat Aug 23 19:47:05 CEST 2008


Kent Johnson wrote:
> The \ character is a special 'escape' character that is used to insert
> non-printing characters into a string. \t represents a single tab
> character, not the two characters \ and t.
> 
> To put an actual backslash into a string, you can either double it:
> 'c:\\tmp\\junkpythonfile'
> or prefix the string with r to make a 'raw' string, which doesn't have
> any special meaning for \:
> r'c:\tmp\junkpythonfile'

While I don't use Windows myself, I'm believe that you can also use
forward-slashes as the path separator, e.g.: 

junkfile = open('c:/tmp/junkpythonfile','w')

(Pardon me if I'm completely wrong.)

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To grasp the true meaning of socialism, imagine a world where
everything is designed by the post office, even the sleaze.
    -- P.J. O'Rourke

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 542 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20080823/696fb1b0/attachment.pgp>


More information about the Tutor mailing list