Familiarity with Python programming language

In this article, we want to provide a brief and informative overview of the Python programming language.

Python has become one of the most popular programming languages ​​in the world in recent years. It is used in everything from machine learning to website building and software testing. It can be used by developers and non-developers alike.

Python is a general-purpose language, which means it’s designed to be used in a range of applications, including data science, software and web development, automation, and generally getting stuff done.

Let’s take a closer look at what Python is, what it can do, and how you can start learning it.

What is Python?

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP.

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today.

Stack Overflow's 2022 Developer Survey revealed that Python is the fourth most popular programming language, with respondents saying that they use Python almost 50 percent of the time in their development work. Survey results also showed that Python is tied with Rust as the most-wanted technology, with 18% percent of developers who aren't using it already saying that they are interested in learning Python [1].

Did you know? The name Python comes from Monty Python. When Guido van Rossum was creating Python, he was also reading the scripts from BBC’s Monty Python’s Flying Circus. He thought the name Python was appropriately short and slightly mysterious.

Python is an interpreted language, which means the source code of a Python program is converted into bytecode that is then executed by the Python virtual machine. Python is different from major compiled languages, such as C and C++, as Python code is not required to be built and linked like code for these languages.

What is an Interpreted Language?

Any programming language that is not in machine code before runtime is considered an interpreted language. An interpreted language is a computer programming language in which instructions are executed without being compiled into machine instructions.

In other words, unlike compiled languages, an interpreted language does not require prior translation. The translation occurs concurrently with the program’s execution.

Why Python is Interpreted Language?

The most common statement published in various books is that Python is an interpreted language, but the hidden fact is that Python is both compiled and interpreted.

When you write a Python program, it is first in the form of source code. This source code must be converted into an executable form that can be run by a computer. There are two ways to do this:

  • Compilation: In this process, the source code is translated into machine code or bytecode ahead of time. The resulting compiled code can be executed directly without any further processing. Python uses a compiler to transform the source code into bytecode, which can be executed by the Python virtual machine. This is how Python code is executed in environments like PyCharm, Visual Studio Code, or other integrated development environments (IDEs) that use Python’s static analysis tools.

  • Interpretation: In this process, the source code is interpreted and executed directly by the interpreter at runtime. When you run a Python script from the command line or an interactive shell, the interpreter reads the source code and executes it line by line. This is how Python code is executed in interactive environments like Jupyter notebooks, or in web applications where Python code is executed on the server side.

Python’s compilation and interpretation work together to provide a flexible and dynamic programming environment. When Python code is compiled, the resulting bytecode can be cached and reused for faster execution in the future. This also allows for some level of static analysis and optimization of the code. When Python code is interpreted, it allows for rapid development and debugging, and provides a more interactive programming experience.

Steps of Execution

  1. A Python source code is written by the coder. File extension: .py

  2. The Python source code a coder writes is compiled into python bytecode. In this process, a file with the extension .pyc gets created.

  3. The Virtual Machine executes the .pyc extension file. Consider the Virtual Machine is the runtime engine of Python. This is where the Python program runs.

Therefore, the Python Interpreter includes the process of Program Compilation, which in-turn compiles into bytecode, then the execution by Virtual Machine.

Let us see the following illustration to understand the execution process in a better way:

Create a .pyc file

To create a .pyc file in Python, use the PyCompile.

The py_compile module

The py_compile module provides a function to generate a byte-code file from a source file, and another function used when the module source file is invoked as a script. The py_compile.compile() compile a source file to byte-code and write out the byte-code cache file.

Now, let us see the example:

import py_compile
py_compile.compile("demo.py")

Use the py_compile.main():

import py_compile
py_compile.main(['File1.py','File2.py','File3.py'])

The compileall module

The compileall module provides some utility functions to support installing Python libraries. These functions compile Python source files in a directory tree. This module can be used to create the cached byte-code files at library installation time, which makes them available for use even by users who don’t have write permission to the library directories.

You can also compile from the command line using the compileall module:

python -m compileall <file_1>.py <file_2>.py <file_n>.py

Compile every single file in the mentioned directory. The compile_dir() recursively descend the directory tree named by dir, compiling all .py files along the way. Return a true value if all the files compiled successfully, and a false value otherwise:

import compileall
compileall.compile_dir(direname)

Use compileall.compile_file(): The compile_file() method compile the file with path fullname. Return a true value if the file compiled successfully, and a false value otherwise:

import compileall
compileall.compile_file('YourFileName.py')

History of Python

Python, introduced by Guido van Rossum in 1991, is a versatile, high-level programming language. It gained popularity due to its simplicity, readability, and powerful syntax. Python's design philosophy emphasizes code clarity and a comprehensive standard library. It has been widely adopted for web development, data analysis, scientific computing, and artificial intelligence. Over the years, Python has evolved, with major releases such as Python 2 and Python 3, solidifying its position as one of the most popular programming languages.

Python Version History

Python Software Foundation (PSF) used to support two major versions, Python 2.x & Python 3.x. PSF supported Python 2 because a large body of existing code could not be forward ported to Python 3. So, they supported Python 2 until January 2020, but now they have stopped supporting it.

Python 3.0 was released on December 3rd, 2008. It was designed to rectify certain flaws in the earlier version. This version is not completely backward-compatible with previous versions. However, many of its major features have since been back-ported to the Python 2.6.x and 2.7.x version series. Releases of Python 3 include utilities to facilitate the automation of Python 2 code translation to Python 3.

The following table lists all the important versions of Python:

VersionRelease DateImportant Features

Python 1.0

January 1994

  • Initial release of Python

Python 2.0

October 2000

  • Introduction of list comprehensions and a garbage collector.

  • Addition of a ternary conditional operator.

  • Improved Unicode support.

  • Introduction of the PEP (Python Enhancement Proposal) process.

Python 2.7

July 2010

  • Last major release of the Python 2.x series.

  • Added support for various new libraries and modules.

  • Improved performance and stability compared to earlier versions of Python 2.x.

Python 3.0

December 2008

  • Major release that introduced backward-incompatible changes.

  • Improved Unicode support.

  • Removal of old and deprecated features.

  • More consistent and cleaner syntax.

  • Enhanced performance in certain areas.

  • Better handling of exceptions.

  • Introduction of the "print" function as a built-in function.

Python 3.6

December 2016

  • Introduction of formatted string literals (f-strings).

  • Addition of asynchronous generators and comprehensions.

  • Improved syntax error handling.

  • Better support for type hints and annotations.

Python 3.8

October 2019

  • Introduction of the assignment expression (the walrus operator).

  • Added support for the f-strings debugging feature.

  • Improved performance and optimizations.

  • Enhanced syntax and features for dictionaries and sets.

Python 3.9

October 2020

  • Addition of the zoneinfo module for handling time zones.

  • Improvement in dictionary merging with the union operator.

  • Enhanced support for type hints and annotations.

  • Improved syntax and semantics for decorators.

Python 3.10

October 2021

  • Introduction of pattern matching using the match statement.

  • Addition of the zoneinfo module for standardized time zone names.

  • Enhanced error messages and diagnostics.

  • Improved performance and new optimizations.

What is Python used for?

Python is commonly used for developing websites and software, task automation, data analysis, and data visualization. Since it’s relatively easy to learn, Python has been adopted by many non-programmers such as accountants and scientists, for a variety of everyday tasks, like organizing finances.

What can you do with python? Some things include:

  • Data analysis and machine learning

  • Web development

  • Automation or scripting

  • Software testing and prototyping

  • Everyday tasks

Python is popular for a number of reasons. Here’s a deeper look at what makes it so versatile and easy to use for coders.

  • It has a simple syntax that mimics natural language, so it’s easier to read and understand. This makes it quicker to build projects, and faster to improve on them.

  • It’s versatile. Python can be used for many different tasks, from web development to machine learning.

  • It’s beginner friendly, making it popular for entry-level coders.

  • It’s open source, which means it’s free to use and distribute, even for commercial purposes.

  • Python’s archive of modules and libraries—bundles of code that third-party users have created to expand Python’s capabilities—is vast and growing.

  • Python has a large and active community that contributes to Python’s pool of modules and libraries, and acts as a helpful resource for other programmers. The vast support community means that if coders run into a stumbling block, finding a solution is relatively easy; somebody is bound to have encountered the same problem before.

Last updated