[Tutor] Open file error

Python python at venix.com
Tue Jan 17 18:50:06 CET 2006

On Tue, 2006-01-17 at 09:11 -0800, andy senoaji wrote:
> I am starting to pull my hair here. There were some postings in the
> past, similar to my problem, but the response was not clear enough.
> Sorry if you thingk I am reposting this.
> I am trying to run (on an XP box) a simple open file using this: 
> f = open(r'C:\Test.txt', 'r')
This looks correct!

> but it keeps give me nagging error of:
> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in -toplevel-
>     f = open('Test.txt', 'r')
This is not the same is the line above!

> IOError: [Errno 2] No such file or directory: 'C:\Test.txt'
And this does not match *either* of the lines above. 

If you really use that first line, I would expect it to work.  If you
get an error, from that line, the file will be identified as:

> I know for sure that the file is there, I even put copies of the files
> here and there, just to guess how python does the file search, but it
> keeps giving me 'No such file or directory'. i also tried variation of
> the file location string, but gave me a variation of errors :). Any
> suggestions?
> Furthermore, how does Python assumes the search path? Will it look
> at /LIB first? How does it knows drive lettering, network mapping etc?
> Is there a configuration settings that I can tweak in my Python? FYI I
> am using Activestate's. 
> Thx,
> Andy 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
Lloyd Kvam
Venix Corp

More information about the Tutor mailing list