[Tutor] (no subject)

Alan Gauld alan.gauld at btinternet.com
Fri Sep 7 20:13:31 CEST 2007


"Lawrence Barrott" <lawrence.barrott at btinternet.com> wrote

> using the built in function "open" how do you specify non local
> files such as the C: drive without copying the program there

Just provide the full path to the file.

f = open(r"C:\TEMP\somefile.txt")

Note the use of raw to avoid problems with the DOS backslash 
character.
Another option is to use forward slashes which python accepts too:

f = open("C:/TEMP/somefile.txt")


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list