In this post we’ll stop looking at language features for a moment and instead check how to start a Python program from the command line.
We’ve been working in the PyCharm environment to write our Python code. However, you could just as well open Notepad and write Python code there. The main thing to note is that Python source files have the file extension ‘.py’, like “helloworld.py”, “customers.py” etc. If you save your Python source code as a ‘py’ file then you can instruct Python to execute it for you.
…then it means that the operating system cannot find any executable (.exe) file called Python. That’s easy to fix.
Make sure you don’t miss the closing semi-colon. Click OK on every window until all of them disappear.
Press Ctrl+C to exit the command line.
That was fairly easy right? We didn’t have to perform any steps before running our Python source code.
In the next post we’ll look at how to write functions in Python.