for root, dirs, files in os.walk(rawsource):
print("root is {}".format(root))
try:
os.system("cd {}".format(root))
print("root in the try: was {}".format(root))
print("pwd is {}".format(os.system("pwd")))
I am not sure why: os.system("cd {}".format(root))
is failing. Meaning, it doesnt appear to properly be changing directory cd
to the value of root
, but instead appears to be staying at /Users/user/Project
But, print("root in the try: was {}".format(root))
is properly outputting the proper directory within the loop.
This is the output:
pwd is 0
root is /Users/user/Project/src/main/gateway
root in the try: was /Users/user/Project/src/main/gateway
/Users/user/Project
Why might this be happening?