Introduction to Python

This post is an introduction to the programming language Python.

Understanding Python

What is Python?

Python is a high-level, object-oriented, dynamically typed and interpreted programming language.

Its first version was released on 1991, but it has received major updates over the time. The latest version update was Python3 on 2008.

Python is owned by the Python Software Foundation (PSF).

It has a BSD-based license, meaning that it is free and open source (FOSS), what attracts some developers and explain its popularity among some communities like Linux users.

You need to have a Python virtual machine installed in your computer in order to run a Python application. The Python interpreter is called CPython.

As an interpreted language, what is the interpreter for Python?

The are different Python interpreter implementations, being the most popular:

  • CPython
  • PyPy

CPython performs interpreted execution, with no execution at all.

PyPy is a just-in-time (JIT) compiler, adding a real-time compilation step as soon as it is executed.

What are the advantages of using Python?

One main characteristic that makes Python different to others is that it is dynamically typed. Because you do not need to worry about the variable types, it is easier and it is common among beginners and casual programs.

Python is sometimes referred as a glue language, because it is often used to connect large software components.

There are multiple libraries available for Python, and you can find some examples on this post.

Python is supported by a numerous and active community.

What are the disadvantages of using Python?

One critique about Python is that it is not as mature as other established programming languages.

Another critique is that is performance is not as good as other languages like C, C++ or Rust.

Do I need to compile Python source code?

Source code files include the logic of the application in a format that is readable by a human. These files have .py extension file.

The interpreter CPython is not able read source code directly, and it needs it to be converted to bytecode, in the same way as other interpreted languages as Java.

Once a .py file is compiled, a new file .pyc with complied bytecode is generated.

Are there different versions of Python?

There has been different versions of Python during its history.

As of 2023, Python 3 is the latest version and it is not backwards compatible. It was released on 2008.

Python 2 support ended on January 2020.

When you read about Python, most probably they are talking about Python 3.

Does the user need to have Python installed on their computer to run an app? Is not that a drawback?

Generally speaking, Python scripts need a Python interpreter (CPython) installed in a computer to run the compiled bytecode.

Nevertheless, there are ways to create standalone files from the Python script (binaries) that can be run on specific OS without the need of an interpreter. So the short answer to the question would be ‘no’, as we can avoid the requirement of having Python installed on a computer to run one of its programs.

One of the advantages of interpreted language is that the same file can be run on any computer without modifications. A drawback is that you need to have installed a Python interpreter (CPython) on each computer where it is going to run.

Alternatively, you can create an standalone executable file that does not require to have CPython previously installed, but on the other hand it will work only on specific platforms and the file will lose its portability.

Python Programming Language

You can read more about Python programming language syntax and common solutions on this post.

Python Tools

What are useful tools for Python?

python3-dev contains Python development libraries.

python3-pip installs Python modules.

python3-venv creates Python virtual environments.

How to install Python

Python installation instructions may differ depending on the OS.

Installing Python on Linux

Python is probably installed by default on Linux OS, but not on its latest version. You can add a repository to Linux in order to ensure you have the latest version.

To check Python version on Linux OS:

$ python3 --version

To install Python3:

$ sudo apt install python3

If you want to intall a specific version of Python, you can add a dot plus the version number after “python3”.

For example, if you want to install Python 3.11:

$ sudo apt install python3.11

To add the repository containing the latest versions to Linux OS, open a terminal and type:

$ sudo add-apt-repository ppa:deadsnakes/ppa

To test that Python works,  go to a terminal and type:

$ python3

Installing Python on Windows

Go to this external link and download Python for Windows.

Follow the installation wizard instructions.

Installing Python on macOS

Go to this external link and download Python for macOS.

Follow the installation wizard instructions.

You might be also interested in…

External references

3 Comments

Leave a Reply to Web Back End Development – RunModuleCancel Reply

Your email address will not be published. Required fields are marked *