Introduction
Python is among the most popular programming languages today. Programming languages are a set of instructions that help humans and computers to communicate. The name python originated from a popular series on BBC named “Monty Python’s Flying Circus”.
Python has been regarded as the most flexible, easy-to-learn, powerful open-source programming language. Its use varies from web development, games development, machine learning, and data science, just to mention a few. Its primary focus is to ensure the creation of easy-to-read code.
The first Python release was in February of 1991 by Guido van Rossum as the ABC programming language successor. This first release was called Python 0.9.0. This version contained functions, exception handling, classes and inheritance, and core data types such as lists, dictionaries, and strings. Since then, several versions have been developed, with the current stable version as per the writing of this blog being 3.9.7. Version 3.10 is under development and testing.
In terms of ranking, Python ranks among the top three programming languages. Functional programming, structured programming, and object-oriented programming are some of the programming designs supported by Python.
Python is currently used by the vast majority of companies, including Google, Instagram, Facebook, and Shopify. A growing Python community has helped build a wide range of libraries used to carry out various tasks.
Python Versions
Python version 1.0 was reached in January of 1994. Tools for functional programming such as lambda, filter, map, and reduce were the major additions for this release.
Python version 2.0 led to the introduction of garbage collectors and lists comprehensions. 2.1 included language specification changes. 2.2 entered the scene in 2001 and led to the unification of python types and classes into a hierarchy that led to python object models becoming object-oriented. Generators were also added to this version. The ‘with
‘ feature was released in 2006 in Python version 2.5. The ‘with
‘ feature helps in developing clean and concise code for exception handling. Version 2.6 and 2.7 were released parallelly with version 3.0 and 3.1, respectively. Therefore Python 2.7 included features of python 3.1.
Python version 3.0 was released in 2008 with the main aim of removing redundant features. The main idea was to ensure that there was only one way of doing something. Major designs such as functional programming, object-oriented and structured programming were still possible in this release. Major features included:
- Changing
print
to a built-in function - Renaming of the Python v2
raw_input()
method to input and removing of the Python v2input()
method - Reduce moved to
functools
from the built-in namespace - Unification of the string type and introduction of the immutable type
- Change in the integer division so that
5/2
is2.5
rather than2
and providing another symbol for the older version of division as5//2=2
>>> print(5/2) 2.5 >>> print(5//2) 2 >>>
Current Python Versions
The current stable Python version is 3.9.7
Some of the new features in Python version 3.9 include:
1. Union operators added to dict to help in merging dictionaries. A new dictionary will be returned from the union consisting of merging the left operand with the right operand.
Example in code
>>> dict1={'Maths':50,'English':70,'History':80} >>> dict2={"Name":"Sarah","Age":30,"Course":"Computer Science"} >>> dict1|dict2 {'Maths': 50, 'English': 70, 'History': 80, 'Name': 'Sarah', 'Age': 30, 'Course': 'Computer Science'}
2. Use of type hinting in standard collections
>>> a=list[str] >>> b=[] >>> a==b False >>> a list[str] >>> b [] >>>
3. Decorator grammar restriction relaxed
4. New methods for strings to remove prefix and suffix
str.removeprefix(prefix) str.removesuffix(suffix) >>> a='dental' >>> a.removeprefix('den') 'tal' >>>
5. New modules added such as zoneinfo
and graphlib
.
Future Python Versions
Python 3.10 is in pre-release
It was pre-released in September 2021
New features in Python 3.10 include:
- Improved error messages, e.g., the inclusion of where unclosed parentheses are in the error messages instead of just ‘syntax error’ and errors that pointed to string literals that were not closed now instead of EOL/EOF they point to the start of the string. Exceptions raised now show the full error
- Replacing
'=='
in comparisons with'='
- Structural pattern matching in the form of match and case statements similar to the switch case in C or C++.
- New union type for type hinting with the syntax
X|Y
instead typing.union()
. For example, it is possible to writedef function(x:int|float)
without importing anything. - Using parentheses in content managers: The use of parentheses in content managers to enable continuity across multiple lines is now supported.
Python 3.11 is under development
Python 3.11 is also under development, and a few new things are in the coming. Some of the things mentioned in the documentation as new things in Python 3.11 are:
- An improvement in error locations: this seems to be an effort to improve what was introduced in Python 3.10 in terms of improved error messages.
- Information about code objects columns