In Linux and Macintosh you want to have a #! statement on the first line indicating the interpreter to be loaded. You also need to make sure the script has the permission to execute. chmod +x ./myscript.py Then in terminal or a Xterm window you can do ./myScript.py I believe I sent an article this morning describing the #! line found on UNIX systems. Best wishes, Jonathan On Apr 29, 2014, at 8:21 AM, Hrvoje Katić <hrvojekatic@xxxxxxxxx> wrote: > Hello, > I just want to add that if there's a traceback or error in your code, you > will not be able to see it if you run .py script just by pressing Enter on it > since command line window will close instantly. > So what I do is I open a folder with .py script, and I make sure that all > files are unselected. Next, I press shift+applications key and then I choose > Open command window here option. After that, I type in hello.py and press > Enter. Then I can review the error details with my review cursor. That's how > it functions on Windows. I have to check out how it works on Linux when I > will be logged in at my Linux system, and I don't know for the Mac. > Anyway, I will be glad if I can help You all with learning Python. I already > wrote some programs with it such as SkypeTalking and PrintList as well as > Extended Winamp appmodule for NVDA. I started to learn Python since 2009, and > it's my favorite language, although it's not fast like C++ or JAVA, but > definitely easier to learn and debug code. My Python experience is definitely > not the best, but it grows up from time to time. > > Regards, > Hrvoje > > Dana 29.4.2014. 0:23, James Scholes je napisao: >> To answer your questions about Python and how it interacts with >> Terminal: Python is what we call an interpreted language, which means >> that instead of compiling your entire program into machine code, i.e. an >> executable, the Python interpreter runs your program one instruction at >> a time. So, if you tell it to run a file called hello.py, and that file >> contains these lines: >> >> print "Hello world!" >> print "Goodbye!" >> >> The Python interpreter will run those lines, one after the other until >> it reaches the end of the file. So you will, of course, see: >> >> Hello world! >> Goodbye world! >> >> If there are any errors while doing this, the interpreter will pick up >> on them and give you some useful information, called a traceback, to >> tell you what your program was trying to do when it failed and what >> exactly went wrong. So if we make a typo on the second line and try to >> run a program containing: >> >> pritn "Goodbye world!" >> >> You will see: >> >> Hello world! >> File "hello.py", line 2 >> pritn "Goodbye world!" >> ^ >> SyntaxError: invalid syntax >> >> First, our correctly typed statement is run, so we see our "Hello >> world!" message. But then, because we typed the N and the T in the word >> "print" the wrong way round, Python tells us we've made a syntax error. >> It also gives us the line number, the line of code being interpreted >> for convenience, and if you can see or be bothered counting the spaces, >> a visual representation of exactly where the syntax error was found on >> the line of code. We're also told that the offending code is contained >> in hello.py, which is invaluable information when you are writing >> programs with many different code files. >> >> The Python interpreter, on most systems, is invoked simply by typing >> "python" at the command line (or Terminal). This is a program, just >> like any other, so on Windows it must be installed. On Mac OS X and >> most flavours of Linux, a version of the interpreter is preinstalled >> which will be sufficient for your learning. When following the >> exercises in Learn Python the Hard Way, most of the time you will run >> Python with one argument; the name of the file you want to run. For >> example, "python hello.py". If you invoke the interpreter with no >> arguments, i.e. by simply typing "python", you will get an interactive >> prompt which allows you to run lines of Python code instantaniously. >> For example: >> >> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> print "Hello world!" >> Hello world! >>>>> 10 + 10 >> 20 >>>>> 14 / 7 >> 2 >>>>> exit() >> Hope that helps. > > Best wishes, Jonathan