Really, really annoying problem
Brett Lempereur
a.lempereur
Wed Sep 20 16:27:05 EDT 2000
There's gotta be a way around this.
Maybe a temporary string conversion of sorts...
Fredrik Lundh <effbot at telia.com> wrote in message
news:g19y5.1228$n4.106912 at newsc.telia.net...
> Brett wrote:
> > > - how do you know that the backslashes are doubled?
> > > (in other words, how did you print the filename?)
> >
> > Because I do this:
> >
> > filename = tools.addroot("ppdump.cfg")
> > file = open(filename, "w")
> >
> > The error occurs at the "open(filename, 'w')" stage, where it raises the
> > double backslash error
> >
> > The error message from python is....
> >
> > Traceback (most recent call last):
> > File "D:\Python\Pythonwin\pywin\framework\scriptutils.py", line 301,
in
> > RunScript
> > exec codeObject in __main__.__dict__
> > File "C:\My Documents\Python\Backup Program\Lib\recurse_test.py", line
17,
> > in ?
> > out_file = open(out_filename)
> > IOError: [Errno 2] No such file or directory: 'C:\\ppdump.txt'
>
> note the quotes around the filename -- tracebacks
> use 'repr' too:
>
> >>> filename = "spam\\egg"
> >>> print filename
> spam\egg
> >>> file = open(filename)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> IOError: [Errno 2] No such file or directory: 'spam\\egg'
> >>> print filename
> spam\egg
> >>>
>
> (also note that there's no "w" in your recurse_test script.
> maybe that's the real problem here?)
>
> </F>
>
More information about the Python-list
mailing list