error in os.chdir

Karsten Hilbert Karsten.Hilbert at gmx.net
Sat Jun 30 09:12:42 EDT 2018


On Sat, Jun 30, 2018 at 05:46:59AM -0700, Sharan Basappa wrote:

> > >> The quick fix:
> > >> 
> > >> put an r in front of the directory string: r'...'
> > 
> > Please don't do that. It's the wrong solution -- all you are doing is 
> > postponing failure. It will *seem* to work, until one day you will write 
> > something like this:
> > 
> >     directory = r'D:\directory\'
> > 
> > and you will get a mysterious failure. Chris gave you the right solution: 
> > use forward slashes instead of backslashes for all paths.
> 
> alright. I will do that but still I don't have an answer why I got the error in the first place.

For that you'll have to read up on strings and escaping.

	https://docs.python.org/2/tutorial/introduction.html#strings

Karsten
-- 
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



More information about the Python-list mailing list