

Note: The first rule of thumb to remember when using Python is that if you’re in doubt about what a piece of Python code does, then launch an interactive session and try it out to see what happens. Here’s an example of how to do this on Linux: To start a Python interactive session, just open a command-line or terminal and then type in python, or python3 depending on your Python installation, and then hit Enter. As a piece of code typed into an interactive sessionĪ widely used way to run Python code is through an interactive session.The interpreter is able to run Python code in two different ways: Therefore, the first condition to be able to run Python scripts is to have the interpreter correctly installed on your system. Whatever form the interpreter takes, the code you write will always be run by this program. A program written in Python itself, like PyPy.A program written in C, like CPython, which is the core implementation of the language.Technically, the interpreter is a layer of software that works between your program and your computer hardware to get your code running.ĭepending on the Python implementation you use, the interpreter can be: The interpreter is the program you’ll need to run Python code and scripts. Python is also a piece of software called an interpreter. Python is an excellent programming language that allows you to be productive in a wide variety of fields. Remove ads What’s the Python Interpreter?

In either case, the important thing is to know how to run the Python code you write into your modules and scripts. So, the main difference between a module and a script is that modules are meant to be imported, while scripts are made to be directly executed. On the other hand, a plain text file, which contains Python code that is designed to be imported and used from another Python file, is called module. Scripts are always processed by some kind of interpreter, which is responsible for executing each command sequentially.Ī plain text file containing Python code that is intended to be directly executed by the user is usually called script, which is an informal term that means top-level program file. This is usually a simple program, stored in a plain text file. In computing, the word script is used to refer to a file containing a logical sequence of orders or a batch processing file. Upon completion you will receive a score so you can track your learning progress over time: Take the Quiz: Test your knowledge with our interactive “How to Run Your Python Scripts” quiz.
