By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

A query related to os.chdir

P: 2
Hi guys,
I have 2 variables a and b and the following code
a= /user/temp/new
b= test

I am using
Expand|Select|Wrap|Line Numbers
  1. os.chdir(os.path.join('a','b'))

to change my directory to test but I am getting following error
Traceback (most recent call last):
File "", line 50, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'a/b'

But I have test directory in new.
Can any one explain me how to resolve this error
Aug 14 '15 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 619
print os.path.join('a','b') to see what the resultant directory is and if it does exist. Take a look at variables vs. strings, and pay attention to which use quotes and which do not, at
Aug 15 '15 #2

P: 3
remove the quotes from i.e.
Expand|Select|Wrap|Line Numbers
  1. os.path.join(a, b)
putting quotes mean you are joining strings not the variables created a line before
Aug 15 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.