In today’s article we will look at how to download and install Python and execute the code. We will also have a deeper look at how Python handles the code and translates it into machine understandable form. The latest available public release of Python is 3.9.6 and can be run on Windows, macOS or Linux/Unix platforms.
Table of Contents
Downloading & Installing Python
To download Python, visit the official download page. Choose the download which is appropriate according to your operating system or select the version you’d prefer. After downloading the installer and running it, you are given two main choices either to ‘Install Now’ or to ‘Customize Installation’.
The first option installs with the default path on the C: drive and recommended features while the second allows you to configure the path and features which you’d like according to your preferences. It is also advisable to enable the check boxes at the bottom for the Python launcher and adding the python PATH to windows configuration to enable ease of access.
If you proceed with further installation and encounter no errors, you are ready to begin running python code.
Text editors/IDEs for Python
While Python installation comes bundled with IDLE which can be used to run python code, for working with much larger programs a specialized text editor or IDE is recommended. Default code editors are usually lightweight and suitable for learning but lack in features which can aid in running even larger or complex programs.
IDEs(Integrated Development Environments) come with advanced features such as build automation, code linting/highlighting, code completion display of file hierarchy, testing/debugging or support for additional extensions which can simplify the coding process/maintainability.
Some of the text editors/IDEs suitable for python development are:
- PyCharm: Pycharm is an specially designed open-source IDE for the Python language, it was created by the company Jetbrains. It is very suitable for professional Python development. It has a free community edition but also a premium version which comes with additional features.
- Visual Studio Code: It is very popular in recent times, and was developed by Microsoft. It is cross-platform and can be run on Windows, Linux or macOs platforms. Microsoft has provided an additional extension for Python development along with official documentation.
- Sublime Text Editor: Sublime editor is commonly used for python development, and also supports installing extensions written in Python. It is also cross platform and hence can be used in Windows, Linux or macOS platform. While Sublime is free for initial usage, a purchase of license is required for further continued usage.
- Atom text editor: An open-source text editor created by the developers of Github, it has a separate package to add additional features suitable for python code execution
How Python handles execution of code
Compilers are programs that usually convert/translates higher level programming language source code into lower level language executable code. Interpreters on the other hand directly convert the programming languages to machine code. Python works in a similar way to interpreted languages while also implementing compiled code logic, it does not directly convert the program to machine code but rather converts the program to byte code/intermediate code which is then executed by a PVM.
This method of implementation is also followed in Java code execution. The intermediate code/ byte code has the .pyc or .pyo extension file format
The Python code then discards the temporary intermediate code files when the program is terminated. Since Python 3, these files are usually stored in the __pycache__ folder which is created automatically. If Python lacks sufficient access to create new files the programs are still executed as the intermediate code is stored in the program’s memory.
In the next article, we will go through the python functions or keyword usage within the programming language along with more basic programs.