On Saturday, 30 June 2018 18:55:53 UTC+5:30, Karsten Hilbert wrote: > 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
sorry. I mean why my code worked in one case but did not in the other one. This worked - os.chdir('D:\Projects\Initiatives\machine learning\programs') This did not work - os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion') only difference is, I added an additional directory in the problematic case. -- https://mail.python.org/mailman/listinfo/python-list