On Tue, 17 Jan 2006, Paul Kraus wrote: > On Tuesday 17 January 2006 12:11 pm, 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')Newbie here but shouldn't it be. > > Newbie Here > > f = open( r'C:\\Test.txt','r') > > I think you are escaping the T with \T.
No, not if he's indicating a raw string (r' '). It should work: >>> f = open(r'C:\Test.txt', 'r') >>> f <open file 'C:\Test.txt', mode 'r' at 0x00AE9410> Although, even with non-raw strings, I prefer to use the forward-slash, making escaping unnecessary: >>> f = open('C:/Test.txt', 'r') >>> f <open file 'C:/Test.txt', mode 'r' at 0x00AE9578> But I suspect that won't help our questioner. My only suggestion is that he make very certain that the file's really there. For example, what does he get if he types: type c:\Test.txt from the DOS prompt? _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor