[Tutor] os.path.join on windows 2000

Danny Ruttle danny@intuitivemedia.com
Wed, 06 Feb 2002 11:18:12 +0000


Sorry about that - I was trying a few directories during tests.

The following call generates the same exception.

if __name__ == "__main__":
     my_instance = line_parser("c:/test","s.txt","test1.txt")

Any ideas?

regards
Dann-o

At 14:52 05/02/2002 -0800, you wrote:


> > -----Original Message-----
> > From: Danny Ruttle [mailto:danny@intuitivemedia.com]
>
> > I have a class which parses the contents of one file and
> > writes to another file - here's a snippet of the constructor:
> >
> > class line_parser:
> > def __init__(self, base_dir, in_file, out_file):
> >
> >          self.handle = open(os.path.join(base_dir,in_file),"r")
> >          <snipped here>
> >
> >
> > Here's the calling line:
> >
> > if __name__ == "__main__":
> >      my_instance = line_parser("c:/site_root","s.txt","test1.txt")
> >
> > Here's the error raised in Windows 2000 Pro:
> >
> > Traceback (most recent call last):
> >    File
> > "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301,
> > in RunScript
> >      exec codeObject in __main__.__dict__
> >    File "C:\Python21\database\pg_extract.py", line 58, in ?
> >      first = line_parser("c:/test","s.txt","test1.txt")
> >    File "C:\Python21\database\pg_extract.py", line 10, in __init__
> >      self.handle = open(os.path.join(base_dir,in_file),"r")
> > IOError: [Errno 2] No such file or directory: 'c:/test\\s.txt'
>
>In your code above the base directory is "C:/site_root" yet in the traceback
>it's listed as "C:/test". Is it possible that W2K is substituting one value
>for another?
>
>Scott
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor