Table of Contents
- Module Preview
- Simple-to-learn
- Simple-to-use
- A great community
- Widely used
- Web development
- Data science
- Education and learning
- Machine and application scripting
- In high demand in the market
- Module 2 Summary
- Module overview
- Python syntax
- General and high-level language
- Multi-paradigm
- Structured programming
- Functional programming
- Object-oriented programming
- Python is interpreted
- Python is managed by the garbage collector
- Python is dynamically typed
- Module 3 Summary
- Module Preview
- Advantage: A complete standard library
- Benefit: Community-driven
- Benefit: Third-party libraries
- Benefit: Third-party tools
- Disadvantages of Python
- Course summary
1. Course Overview
This course aims to introduce you to what makes Python a popular choice within many of today’s large organizations.
Here is what you will learn during this course:
- Python’s design philosophy, its history, and the many technology areas in which Python is used.
- The Python programming language itself: what Python code looks like, what makes it similar, and what sets it apart from other programming languages used today.
- The Pros and Cons of Python: From strengths like a comprehensive standard library and access to great third-party tools, to cons like raw native performance.
At the end of this course, you will have sufficient knowledge of Python to decide whether this language is a value addition to you or your company’s skillset.
This course focuses on Python 3 and is 100% applicable to the versions of Python 3 listed in the course. Although Python 2 is not the main topic, much of the content is still applicable to Python 2. We will briefly touch on Python 2-related challenges you might encounter as you begin your Python 3 journey.
2. Why Python?
Module duration: 17m 43s
Module Overview
Welcome to this module that aims to help you understand the overview of Python, a programming language that is growing in popularity and used in many ways across many industries.
This module does not require any prior in-depth computer knowledge. Although Python code is sometimes shown, you do not need to understand it. This is a “big picture” course (overview): no need to install software or write code.
Two types of profiles can benefit from this course:
- A developer who is considering learning Python for a professional or personal project.
- A senior technical decision maker who wants to learn more about Python and evaluate whether it would be a good fit for their organization.
In this module, we’ll cover five high-level reasons why Python is a great programming language:
- Python is simple to learn.
- Python is simple to use.
- Python has a large community.
- Python is widely used.
- Python skills are in high demand.
Simple to learn
What makes Python a great programming language? First of all, Python is very easy to learn.
Here’s what you don’t need to know to learn and use Python:
- The difference between random access memory (RAM) and a hard drive.
- What is an operating system.
- What a compiler is.
- What build systems are.
- Another pre-programming language.
Whether you are new to computers or not, you can learn Python. Python is designed with a clear goal: to be easy to read and understand. Just as you wouldn’t learn a new written or spoken language by starting with the longest, most complex books, Python makes the code accessible.
If something is difficult to read, it is often difficult to understand. If something is easy to read, it is often easy to understand. Python is here to help you understand programming thanks to its readability efforts. It is a very welcoming programming language to learn.
Simple to use
There are several fundamental principles of the Python programming language that make it simple to use.
There is usually only one way to do things
Some programming languages strongly believe in flexibility — the ability for a developer to solve a problem in many different ways. Python is not one of these languages. Having the ability to solve a single problem in many ways is like having a big box of building blocks without an instruction book, or being faced with a blank canvas where you can paint anything. While this freedom can sometimes be liberating, when you start using a programming language, the constraints are beneficial. They provide guardrails that point toward a likely solution and help maintain momentum.
Simplicity as a guiding principle
This unique way of accomplishing a task also translates into Python’s guiding principle: simplicity. Simplicity breeds ease of use. Excessive complexity introduces confusion. Imagine learning how to use a new device with lots of buttons, levers, and controllers — it would be difficult to figure out how to use it. But with a simplified and intuitive interface, what needs to be done becomes clear and obvious.
The beauty of code
Python and its community encourage beautiful code. The emphasis on beauty makes the user experience more enjoyable. When you don’t enjoy using something, it makes it harder to continue using it. If something provides satisfaction, it increases the desire to continue using it. The Python community has incorporated this principle into the development of language features.
A great community
A major factor contributing to the ease of learning and using Python is the support of the excellent Python community. The Python community has instilled many fundamental principles into the language, which have helped it become what it is today.
Development Support
Community involvement can be seen directly in the way Python is supported and developed:
- Countless third-party Python packages and code libraries are available.
- Great third party tools can be used with Python.
Python Enhancement Proposals (PEPs)
Python development is largely driven by community proposals called Python Enhancement Proposals, also known as PEPs. This process is the main mechanism for:
- Propose major new features.
- Collect community input on an issue.
- Document design decisions that were integrated into Python.
Pending PEPs are reviewed and commented on by the Python community. This process has allowed Python to evolve as a shared language and adapt to changing user needs over many years.
Widely used
Over its many years of existence, the use of Python has continued to grow and become more and more powerful and capable. Python has been used in areas as diverse as special effects in films like Star Wars or as a scripting language in the popular open source 3D modeling application Blender.
Here are four areas where Python has seen widespread use:
- Web development
- Data Science
- Education and learning
- Machine and application scripting
Web development
There are many different styles of web development. Whether for:
- HTTP / REST API: back-end development without front-end user interface.
- Full stack web application: which affects both the client and the server.
- Content Management System (CMS), ERP or other type of application.
Whatever the situation, there is a Python solution for you.
Popular Python frameworks for APIs:
FlaskFastAPIBottlePyramid- and many others…
Popular Python frameworks for full stack:
DjangoTurboGearsweb2py
Complete, self-sufficient web applications:
Django CMSWagtailMezzanine
No matter what type of web application you are developing, Python is already used in this field and can meet your needs.
Data Science
Data science is a field that is growing in popularity every week. This is an exceptionally broad area. Two subfields often included in data science are:
Big Data
As developers, we’re used to thinking about data in terms of kilobytes, megabytes, and gigabytes. But the data is growing quickly. More and more systems now require engineers to think in terms of terabytes, petabytes, and even exabytes.
In 2012, 2.5 exabytes of new data were generated every day — that’s a 2.5 followed by 18 zeros.
Data sets have become so large that existing data processing systems are unable to handle them. This is where the growing popularity of technologies like Hadoop and MapReduce comes from. What was once a problem faced mainly by large companies like Google or Microsoft is now starting to be faced by mid-sized companies. The more data we have, the more we can spot new business trends, find correlations to prevent new diseases, fight crime — and Python is a popular language in this space.
Machine Learning
Machine learning is not directly related to big data, but the more data available, the more powerful machine learning becomes. We are surrounded by data everywhere: large text files, user actions, image and video metadata, networks of relationships. The complexity of the relationships between all of this data is potentially much greater than what a single person or group of people could find alone.
Algorithms are written so that a computer can process all the data and find its own connections between the many different data sources. Machine learning is commonly used in several contexts:
- Determine if an email is spam.
- Detect network intrusions by analyzing abnormal traffic.
- Optical Character Recognition (OCR): Convert text images to text data.
- Computer vision: face detection, object tracking, motion tracking.
New uses of machine learning are discovered every day.
Education and learning
Python is widely used in education and learning, and its popularity in this field continues to grow.
- Python is increasingly being adopted as a language for teaching basic STEM skills to young students around the world.
- It is used as the first programming language to teach programming.
- This use is not just for young students: Python is becoming more and more popular in university courses around the world.
- Python is used as an educational tool to teach computer hardware through accessible maker devices like the Raspberry Pi and micro:bit.
Jupyter Notebooks
A great way Python is used in education is through Jupyter Notebooks. Sometimes the best way to learn is through interaction and exploration of what the code does and the consequences of changing a piece of code.
Jupyter Notebooks, a project born from the interactive Python interpreter IPython, are a great way to share different topics with people and encourage exploration of a given topic interactively, by modifying the code in real time.
Jupyter Notebooks have experienced an explosion in popularity, particularly in the data science space, and are advancing the concept of interactive education, particularly in computer programming.
Machine and application scripting
System Scripting / Administration
One of the most common uses for scripting with Python is computer administration. When writing scripts to administer a machine, it is common to:
- Working with folders and files on the machine (for example, managing a series of log files or examining and monitoring the file system).
- Manage configuration of applications and services.
- Monitor processes running on a system, keeping an eye out for uncontrolled processes.
- Deploy a new application, deploy new versions of an existing application, or delete older applications.
Python supports all of these tasks. The only limit is our imagination, with full access to the wide variety of Python libraries available.
Application scripting
Application scripting is a powerful concept. Usually, as users, we don’t think of an application as something that can easily be extended by us. But imagine if a user or developer could write their own code to respond to events triggered in the app, or even create their own UI elements, new screens, new user flows — and integrate them directly into the app itself.
This is exactly what application scripting is all about, and it’s an area where Python can be used in a very powerful way. It can already be found in:
- 2D and 3D modeling software, especially in popular applications like Blender and Houdini.
- Image manipulation software in the form of different image processing algorithms.
- Photo taking applications in the form of fun overlays on images.
Highly demanded in the market
Python continues to grow in popularity, and the ability to work with Python is a skill that is growing in demand across the industry. Until recently, when many developers thought of popular programming languages, they thought of Java, C#, C++, JavaScript, and perhaps PHP. Python usually didn’t come to mind.
But according to recent analyses:
- Stack Overflow: Python has overtaken languages like Java, C# and C++ in terms of question views.
- PYPL (Popularity of Programming Language Index): Python is now the most popular programming language, with popularity continuing to grow each year.
- IEEE Spectrum: Python has the highest ranking according to a recent report.
- TIOBE Index: Python is now at the top of the most popular programming languages in the world.
All this to say: there is no longer any doubt that Python is a popular programming language and a great language in which to invest your learning time.
Module 2 Summary
In this module, we covered several topics on Python:
- How Python is both simple to learn and simple to use.
- The different areas where Python is seeing continued growth and use.
- The excellent community behind Python.
With the popularity and demand that Python has achieved, it is an excellent time to invest in Python 3.
3. What is Python?
Module duration: 18m 9s
Module Overview
In this module, we will learn what the Python programming language actually is. It is not necessary to know all of the terms that will be used here, nor to understand the code shown. The goal is to give a general impression of the Python language.
On the program for this module:
- The unique Python syntax and its characteristics.
- Python as a general-purpose and high-level language.
- Python support for multiple programming paradigms.
- The flexibility of Python thanks to its interpreted character, managed by the garbage collector and dynamically typed.
Python syntax
Let’s talk a little about Python syntax. Many modern programming languages have what is called C-style syntax, because their syntax is inspired by the C programming language. C syntax is most recognizable by the use of braces ({}) and semicolons (;). Languages like C++, Java, C#, JavaScript and others adopt this style.
Python, however, does not have C-like syntax.
Why did Python make this choice? This can be summarized in two principles taken from Zen of Python:
“Beautiful is better than ugly” “Readability counts”
Because of these principles, Python has made a very unique choice in its syntax: significant whitespace.
Significant white spaces
Unlike Python, whitespace has no special meaning in many languages like C and C++. In these languages, linked code blocks are determined primarily by curly braces. In Python, on the other hand, related blocks of code are grouped according to their level of indentation, thus making white space meaningful.
# Exemple de syntaxe Python avec indentation significative
def saluer(nom):
if nom:
print("Bonjour, " + nom + "!")
else:
print("Bonjour, inconnu!")
saluer("Alice")
saluer("")
Python believes that dispensing with unnecessary braces and semicolons makes code easier to read and understand. While it may be a matter of personal taste, significant whitespace is both a unique feature of Python and a source of controversy among many programmers.
General and high-level language
Python is a general-purpose and high-level programming language.
General language
A general-purpose language means that it can be used in many ways and for different reasons, as we’ve seen with all the different ways Python is used today. This contrasts with special languages designed for use only in specific contexts, such as mathematical calculations, financial data manipulation, or even specific to a single target machine architecture.
High level language
What does it mean for a programming language to be high-level? The level of a language refers to the relationship between the code you write and the instructions the computer executes.
-
Binary code / machine code: At the most fundamental level, computers operate with ones and zeros. Everything a computer does relies on this fundamental level. The code that operates at this level is called machine code. These are what we call low-level languages, where we work extremely close to the hardware, explicitly telling the hardware what to do.
-
High-level languages: With high-level languages, we don’t directly tell the computer’s guts what to do. Instead, we describe what we want to accomplish in human-readable, easy-to-understand language. The language implementation then determines how to tell the computer to perform these actions at the most fundamental level.
The combination of general-purpose usability and high-level programming style provides a very compelling and powerful development experience. By living at a higher level, we don’t have to worry about the hardware specifics of a computer’s inner workings, and we can focus on the problem we’re trying to solve. The code we write is also easier for humans to understand and improve in the future.
Multi-paradigm
There are many different approaches and paradigms for writing computer code. Historically, it was common for a programming language to subscribe to a specific paradigm. But as programming languages have evolved, more of them have started supporting multiple ways to write your code. Python is one of those multi-paradigm programming languages.
Before discussing the paradigms, let’s remember what it means to program a computer. Think of a computer program as an assembly line:
- On one side, we have our input — like raw materials (steel to build a car).
- At the other end we have our output — the completed car.
- Materials and the form they take during the assembly line can be thought of as data structures.
- The various actions performed by workers or machines along the assembly line can be thought of as algorithms.
As Niklaus Wirth said: Algorithms + Data Structures = Programs
Different paradigms are different ways of organizing these concepts to build a program.
Structured programming
Structured programming was a pioneering programming paradigm, developed by computer scientist Edgar Dijkstra. Two most influential advancements:
-
Control structures (control structures): allow us to make simple branches in our program (if/else conditions) and to control iteration (
whileloops,forloops). -
Subroutines (subroutines): allow us to group a set of instructions into a construction which can then be easily called from different parts of our programs, promoting code reuse. Subroutines are found in the form of procedures, functions and methods.
# Exemple de programmation structurée en Python
def calculer_tva(prix, taux=0.20):
return prix * taux
for produit in ["livre", "outil", "vêtement"]:
prix = 50.0
tva = calculer_tva(prix)
print(f"Produit: {produit}, Prix: {prix}€, TVA: {tva}€")
These concepts might seem obvious today, but they solved a major problem at the time: spaghetti code. Without first-class support for control structures and subroutines, a program was primarily a long list of computer instructions with very little explicit organization. The code often had to jump from place to place in this long list of instructions — extremely difficult to read and understand.
Structured programming allows you to provide structure to a long, otherwise chaotic list of instructions. The functionality of the code is directly reflected in the syntactic structure of the code.
Functional programming
functional programming (functional programming) is based on structured programming. It emphasizes the algorithms within a program by focusing on the functions on which the program is built. This stems from a more mathematical approach to computer programming.
With functional programming, it is considered more powerful to have many different algorithms that all operate on a small number of data structures. This encourages algorithmic reuse across problem spaces and aims to allow algorithms to be assembled and used as a single unit.
# Exemple de programmation fonctionnelle en Python
from functools import reduce
nombres = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# filter() - garder les nombres pairs
pairs = list(filter(lambda x: x % 2 == 0, nombres))
# map() - multiplier chaque nombre par 2
doubles = list(map(lambda x: x * 2, pairs))
# reduce() - additionner tous les éléments
total = reduce(lambda acc, x: acc + x, doubles, 0)
print(f"Pairs: {pairs}") # [2, 4, 6, 8, 10]
print(f"Doubles: {doubles}") # [4, 8, 12, 16, 20]
print(f"Total: {total}") # 60
Object Oriented Programming
Object-oriented programming (OOP) also builds on structured programming, but takes a slightly different approach from functional programming. In object-oriented programming, algorithms and the data they operate on are grouped into objects. A program is then built from many different objects that all communicate with each other.
# Exemple de programmation orientée objet en Python
class Animal:
def __init__(self, nom):
self.nom = nom
def parler(self):
raise NotImplementedError("Sous-classe doit implémenter parler()")
class Chien(Animal):
def parler(self):
return f"{self.nom} dit: Woof!"
class Chat(Animal):
def parler(self):
return f"{self.nom} dit: Meow!"
animaux = [Chien("Rex"), Chat("Whiskers"), Chien("Buddy")]
for animal in animaux:
print(animal.parler())
A great strength of Python is that you don’t have to worry about which paradigm is the best tool to use in your project, because Python supports programming in all of these styles. Whether it’s simple structured programming, functional programming, or object-oriented programming, Python has you covered.
Python is interpreted
Python is an interpreted language. Programming languages come in two flavors: interpreted and compiled. Python is, by default, an interpreted language.
To understand the difference, let’s see how we go from a programmer writing code to this program running on a computer.
A CPU (central processor) only speaks its own language — its instruction set architecture. By default, the CPU does not understand the code we write. At some point, the code must be transformed into instructions that the CPU understands.
Compiled languages
One approach is to do this translation before running the program. This is called compilation, and it’s what compiled languages do. For some languages like C++, compiling a large program can take a considerable amount of time. This means that the programmer has to wait a long time before being able to check whether the code does what it is supposed to do.
Interpreted languages
With an interpreted programming language, it’s like having a live translator that translates your code into the language the CPU understands in real time. There is no need to run a compiler first. The language runtime is responsible for understanding your program code and interpreting it into instructions that the CPU understands as the program executes. This is what Python does by default.
You do not need to compile your code first. You write a Python script or program, and the Python runtime will take care of running your program regardless of the type of CPU it is running on.
Important: It is important to know that there are indeed Python compilers that exist, so that Python can be compiled. This means you can benefit from both rapid code improvement and execution speed once the code is ready to be deployed to users.
Python is managed by the garbage collector
To understand garbage collection, we need a rough understanding of how programs and data are stored in a computer.
Von Neumann Architecture
All modern personal computers use a machine architecture known as Von Neumann architecture. In this architecture, a computer is made up of several parts:
- A central processing unit (CPU).
- A memory for storing data and instructions.
- An external storage.
- A set of input and output devices used to interact with the machine.
The Von Neumann architecture evolved into what is often called a stored program computer. This means that programs are stored in the computer’s memory along with the data on which the program operates.
The problem of memory leaks
When a program executes, it reads data from memory and writes different data back to memory. This raises an interesting question: What should happen with data that is no longer in use? If left unchecked, this can lead to memory leaks.
Think of data that is no longer in use like dirty dishes that need cleaning. Who should be responsible for cleaning?
- Native languages (C, C++): The programmer who wrote the program is responsible for garbage collection.
- Modern languages (Python, C#, Java): The language and its runtime are responsible for garbage collection. This is called garbage collection (automatic waste collection).
Advantages of garbage collection
- We don’t have to worry about keeping tedious accounts of all the memory used.
- This helps avoid common memory leaks.
- We can avoid a whole class of security issues related to how memory is manually accessed and cleaned up.
- This also allows effectively implementing some persistent data structures.
There are also disadvantages to garbage collection, which will be briefly discussed elsewhere in this course.
Python is dynamically typed
Python is a dynamically-typed programming language. To understand what this means, let’s take a quick look at what a variable is.
In a program, we read and write data from and to memory. A variable is a way of labeling a memory cell with a friendly name that we can refer to in our code.
# Une variable simple en Python
greeting = "Bonjour, monde!"
print(greeting) # Bonjour, monde!
Data types
Data types allow you to specify what type of data can be stored in a variable (a character string, an integer, etc.).
Statically typed languages
In a statically typed language, we tell the language what types of values can be stored in a variable when we create the variable. For example, we could create a variable called answer and say that only numbers can be stored in it. As long as the variable exists, we can only store numbers. Most statically typed languages are also compiled languages: if you try to write code that attempts to put anything other than a number into this variable, the compiler will report an error and you will not be able to run the program.
Dynamically typed languages
Python being a dynamically typed language primarily means two things to developers:
-
The type of a variable may change during the life of that variable. If we initially put a string in a variable, we can always put a number in it later.
-
Type checking occurs at runtime, while our program is running. If we try to add a string to a number, Python will give us a type error at runtime.
# Illustration du typage dynamique en Python
variable = "Bonjour"
print(type(variable)) # <class 'str'>
variable = 42
print(type(variable)) # <class 'int'>
variable = 3.14
print(type(variable)) # <class 'float'>
variable = [1, 2, 3]
print(type(variable)) # <class 'list'>
Dynamic typing provides a lot of flexibility. One of the behaviors it allows is what is called duck typing.
Duck Typing
Its name refers to the saying: “If it walks like a duck and quacks like a duck, then it probably is a duck.” Python allows any object to be passed into a function as long as it behaves the way the function expects it to. If the function expects a quack method on the object, any object can be passed, as long as it has this quack method.
# Exemple de duck typing en Python
class Canard:
def quack(self):
return "Coin coin!"
class Personne:
def quack(self):
return "Je fais semblant de faire coin coin!"
class Robot:
def quack(self):
return "BEEP BOOP COIN!"
def faire_parler(objet):
# On n'exige pas un type spécifique,
# seulement que l'objet ait une méthode quack()
print(objet.quack())
for entite in [Canard(), Personne(), Robot()]:
faire_parler(entite)
Thanks to duck typing, we can extend our code in the future or even have easier integration with third-party code that might not be able to implement the exact types we would otherwise need.
Module 3 Summary
In this module, you learned the different aspects of design and implementation of the Python programming language:
- Python’s unique syntax based on significant whitespace.
- Python is a general purpose language that can be used in many contexts.
- Python is a multi-paradigm language supporting structured, functional and object-oriented programming.
- Python is very flexible thanks to its interpreted, garbage collected, and dynamically typed nature.
4. Advantages and disadvantages of Python
Module duration: 14m 47s
Module Overview
In this module, we will look at the different advantages and disadvantages of the Python programming language for a new learner. We will talk about:
- Its complete standard library.
- The benefits of Python being community driven.
- The excellent third-party support available for Python development.
- As well as some disadvantages of the language.
Advantage: A complete standard library
When learning a new programming language, one of the first questions we should ask ourselves is: What functionality does it provide in its included standard library?
If you think of Python as anything you can use “out of the box”, you can think of a standard library as a collection of code that you can immediately use to do different things:
- Create user interface.
- Make calls to web services.
- Scan files.
- And many other tasks…
Two Standard Library Philosophies
Philosophy 1: Small, minimal standard library
- The goal is to allow the language and libraries to evolve separately from each other.
- Allows applications to only “pay” for the size and complexity of the features they use.
- The downside: You may need to import a significant amount of non-included code when building a non-trivial application.
Philosophy 2: Complete standard library
- When learning a new language, a comprehensive standard library provides plenty of room to experiment with the language in various projects.
- You can do this without needing to rely on third-party libraries, reducing the amount of learning required.
Python adopts the comprehensive standard library philosophy. The Python standard library of course includes much of the basic functionality that many types of applications will need:
| Category | Examples |
|---|---|
| Data structures | Lists, sets, dictionaries |
| File I/O | Reading and writing files |
| Dates and times | Module datetime |
| Compression and archiving | Modules gzip, zipfile, tarfile |
| User interfaces | Module tkinter |
| Data formats | csv, xml, json modules |
| Audio | Module wave |
This is just the tip of the iceberg. Python also provides excellent documentation for its standard library. With the size and quality of the Python standard library, you can write a lot of different programs before ever needing to go to third-party libraries.
Advantage: Community driven
Beginning with the release of Python 2 on October 16, 2000, the Python development process was changed to become more transparent and community supported through Python Enhancement Proposals (PEPs).
The PEP process is the primary mechanism for:
- Propose major new features.
- Collect community input on an issue.
- Document design decisions made for various features.
Pending PEPs are reviewed and commented on by the Python community and by Guido van Rossum, the creator of Python. This has allowed Python to evolve as a shared language and adapt to changing user needs over the years.
PEP 20: The Zen of Python
The benefits of this approach can be seen as early as PEP 20, often called the Zen of Python. This PEP helped form a common foundation of various Python principles and philosophies that would shape Python for years to come.
Le Zen de Python (PEP 20) — par Tim Peters
Beautiful is better than ugly. (Le beau est préférable au laid.)
Explicit is better than implicit. (L'explicite est préférable à l'implicite.)
Simple is better than complex. (Le simple est préférable au complexe.)
Complex is better than complicated. (Le complexe est préférable au compliqué.)
Flat is better than nested. (Le plat est préférable à l'imbriqué.)
Sparse is better than dense. (Le clairsemé est préférable au dense.)
Readability counts. (La lisibilité compte.)
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
You can access Zen of Python directly in Python:
import this
Transparency of new versions
Another benefit of the PEP process is the transparency that comes with each new version of Python. In each release, the release notes include links to all individual PEPs for all new features and improvements. Digging into a single proposition, we can read:
- Feature previews.
- The feature specification.
- And even objections and concerns regarding functionality.
The Python community connects via
- Mailing lists
- IRC
- Forums
- Special Interest Groups
- Local user groups
- Newsletters
Python Software Foundation (PSF)
The Python Software Foundation is a non-profit organization dedicated to promoting open source technology related to Python. The PSF:
- Actively provides the infrastructure that the community relies on.
- Produced PyCon, the largest annual gathering of the Python community.
- Distributes grants each year to support Python causes.
Advantage: Third-party libraries
Now, there is already a lot you can do with Python “out of the box”, but an added benefit of Python being community driven and embracing community written software is that there is a lot of very useful code available.
Whatever field you work in, there is probably already a library that can help you.
PyPI — Python Package Index
One of the first places we can go to find out what others have written is the Python Package Index, or PyPI. People around the world publish their projects and libraries in the Python Package Index.
pip — The package manager
Working with PyPI is incredibly simple thanks to a tool called pip. Pip is installed by default with many Python distributions and installations.
# Installer un paquet avec pip
pip install requests
# Installer une version spécifique
pip install requests==2.28.0
# Désinstaller un paquet
pip uninstall requests
# Lister les paquets installés
pip list
# Sauvegarder les dépendances dans un fichier requirements
pip freeze > requirements.txt
# Installer toutes les dépendances depuis requirements.txt
pip install -r requirements.txt
Key pip features:
- Install and uninstall Python packages — this is the main function of a package manager.
- Manage dependencies: pip installs and uninstalls not only our own dependencies, but also the dependencies of Python packages we install.
- Package Groups: We can track a package group as a group unit, allowing the group to be installed, uninstalled and managed as a single unit.
- Version control: pip can help us ensure that we are using the correct versions of third-party libraries, avoiding breaking our software by unknowingly using a different version of a package.
Popular libraries by domain
| Domain | Library Examples |
|---|---|
| Data Science | NumPy, Pandas, SciPy |
| Machine Learning | TensorFlow, PyTorch, scikit-learn |
| Web development | Django, Flask, FastAPI |
| Data Visualization | Matplotlib, Seaborn, Plotly |
| Image manipulation | Pillow, OpenCV |
| Tests | pytest, unittest |
Advantage: Third-party tools
Another area where we see the benefits of the Python community and its growing popularity is tooling. Python has many different tools that you can use at all stages of development.
IDEs and editors
There are many IDEs and editors to choose from for writing Python code:
| Tool | Description |
|---|---|
| PyDev | Eclipse-based Python IDE |
| PyCharm | Excellent Python IDE from JetBrains |
| Visual Studio Code | Support Python development with Python extension |
| Spyder | Scientific Python IDE — designed by and for scientists, engineers and data analysts, especially useful with NumPy, Matplotlib |
For a lighter experience without the overhead of a full IDE, many text editors also offer excellent support for Python:
- Sublime Text
- Vim
- Emacs
- And many more…
Code Quality Tools
| Tool | Role |
|---|---|
| Flake8 | Checking style and conventions (linting) |
| PyLint | Static code analysis |
| Black | Automatic code formatter — helps avoid code formatting debates in a team of developers |
Performance Analysis Tools
Major software vendors also offer performance analysis tools for Python, such as Intel’s VTune suite.
As we can see, Python is not just a programming language for amateurs or non-coders. Its third-party ecosystem has helped make it a reference programming language that can be used for major software projects.
Disadvantages of Python
Lest we give the impression that Python is the perfect programming language for all problems, here are three main drawbacks to be aware of. Knowing these drawbacks will help make a more informed decision about whether to use Python.
Disadvantage 1: Python is interpreted → Reduced performance
The fact that Python is interpreted has the negative consequence that it is often quite slow “out of the box”, especially compared to native languages like C, C++, or Go.
Solutions exist:
- There are compilers that allow you to compile your Python to native code for execution, but they are not supported directly “out of the box”.
Disadvantage 2: Python is not a native language
Python is not a native language, which contributed to:
- High memory usage in several cases.
- The absence of a native security sandbox.
These limitations have led to Python not being widely adopted directly in the web browser or on mobile platforms. So while Python continues to see widespread server-side usage, its usage on desktop and mobile is lagging.
Disadvantage 3: Python is a dynamic language → Runtime errors
Although dynamic typing has advantages, it also has disadvantages:
- Errors mainly occur at runtime, where they can be more difficult to diagnose and treat.
- This lack of error diagnosis at the time developers write the code can make refactoring more difficult and make it harder to maintain the code as it evolves.
Solutions to disadvantages
These disadvantages do not necessarily have to block us:
-
For performance: If you really need the performance offered by compiling to native code, there is CPython and the ability to compile code. Even though it’s not in a beginner’s standard workflow, it’s still possible.
-
For dynamic typing: Python has started to introduce optional type hints that allow you to specify the type of a specific variable, similar to what we see in other programming languages like JavaScript with TypeScript. This allows you to stay in the comfort of Python code while gaining benefits you wouldn’t have previously gotten “out of the box”.
# Exemple d'annotations de types optionnelles en Python
def calculer_total(prix: float, quantite: int) -> float:
return prix * quantite
def saluer_utilisateur(nom: str) -> str:
return f"Bonjour, {nom}!"
# Les annotations de types permettent aux IDEs et aux outils
# d'analyse statique de détecter des erreurs potentielles
resultat: float = calculer_total(9.99, 3)
message: str = saluer_utilisateur("Alice")
print(resultat) # 29.97
print(message) # Bonjour, Alice!
For many workloads, the benefits far outweigh the drawbacks. But if you need to build native apps or write high-performance native code, Python may not be the best choice for you. This is a decision that must be made on a case by case basis.
Course Summary
Thank you for watching this course on Python, perhaps the only programming language named after a famous comedy group (Monty Python).
Whether you’re learning to program for the first time or you’re a seasoned professional just learning a new programming language, here’s a recap of what you’ve learned:
Module 2 — Why Python?
- Python is simple to learn and simple to use.
- Python has a great community.
- Python is widely used in many fields.
- Python is in high demand in the market.
Module 3 — What is Python?
- Significant white spaces in Python’s unique syntax.
- Python is both a general purpose language and a multi-paradigm language.
- Python is interpreted and managed by the garbage collector.
- Python is a dynamically typed language.
Module 4 — Advantages and Disadvantages
Advantages:
- Comprehensive standard library — lots of features out of the box.
- Community-driven — transparency and collaborative evolution via PEPs.
- Abundant third-party libraries via PyPI and pip.
- Quality third-party tools: IDEs, linters, formatters, performance analyzers.
Disadvantages:
- Interpreted → slower than native compiled languages “out of the box”.
- Non-native → high memory usage, limited adoption in browsers and on mobile.
- Dynamic language → errors occur at runtime, refactoring more difficult.
5. Useful resources and links
The following resources are mentioned in the course or referenced in the exercise files:
| Resource | URL |
|---|---|
| Python 3 Documentation | https://docs.python.org/3/ |
| Python Standard Library Index | https://docs.python.org/3/library/index.html |
| Python Enhancement Proposals (PEPs) | https://peps.python.org/ |
| PEP 20 — The Zen of Python | https://peps.python.org/pep-0020/ |
| Python Package Index (PyPI) | https://pypi.org/ |
Search Terms
python · foundations · data · analysis · engineering · analytics · language · advantage · disadvantages · languages · advantages · community · disadvantage · interpreted · programming · scripting · tools · typed · application · development · dynamically · garbage · libraries · library