How do you run a python file from cmd or Python Shell or setup a workspace?
Question: I have looked at [this
explanation](http://stackoverflow.com/questions/1522564/how-do-i-run-a-python-
program) on how to put Python as a system variable for `Path`. This worked
successfully and from my `cmd` I can now run python which will result in the
terminal changing to the `>>>` notation.

However, I am not able to run the script `test.py` even when I `cd` into the
right directory. I get the error: `name test not defined`.

My first question is: how can I solve this and should I solve it?

Digging a bit deeper, I also found that there is the **IDLE Python shell**
that comes with the installation of Python. This interface comes provides
support for the `>>>` notation and you can run Python code in it. My guess
that it is better to use this interface to run scripts. However, it is not
clear to me how to cd into the right directory and run the file `test.py`
(located in: `C:\dev`). How should I do run it? Is there a way to `cd` into a
directory/workspace?

So basically, how do I run a python file and where should I run it? cmd or in
the shell?


Answer: The error sounds like you may be correctly changing directories in cmd, then
running python, then entering the name of the file in python. So you are
setting a path in cmd, then you ran python, and gave it an object it doesn't
know.

Since you aren't importing or running this file from within python you need to
tell cmd to run this file in python by changing directory correctly and then
telling it to run in python like so:

    
    
    cd documents/py_scripts
    
    python test.py
    

I would point you to executable scripts using #!/usr/local/bin/python as your
first special line (with your own path to the python interpreter), and using
chmod +x file.py command for unix.

