You seem to have opened interactive mode of python. I am not 100% sure, but I would actually bet my finger that cwd
on Windows and *NIXes is by default set to the directory the interpreter was invoked from.
So the question is how did you open your python shell ? Probably from C:\Program Files\Python33
or used some IDE that started it with cwd
being the actual direcotry where the python binary resides.
You can pretty much place your files whenever you want, and work relatively from there. However you have to adjust your cwd
accordingly. By any means. Usually IDEs provide some project options to set cwd
manually. You can run your script from some base directory. E.g.
cd D:
cd D:\my_python_dir\
python test.py
Should work. Also not giving test.py
as second argument should start interactive shell and os.getcwd()
should give D:/my_python_dir
or an equivalent result.
Lastly if you are using interactive shell you can always use other os
function os.chdir(path)
.