Document de travail sur le plan de la formation py-edu-fr-init#
About#
Note
This is an historical document. We now can work and modify the source of the py-edu-fr-init training.
Note
Ce potentiel cours (dépôt ici https://foss.heptapod.net/py-edu-fr/py-edu-fr-init) est à destination de personnes avec pas ou peu d’expérience en Python mais (i) quelques bases en programmation et (ii) un niveau Master ou plus ou formation permanente. Ce n’est donc pas un cours pour (i) des vrais débutants en programmation (les notions de variables et de boucles doivent être connues) ni pour (ii) des lycéens ou étudiants en 1er cycle universitaire. Une maîtrise correcte de l’anglais à l’écrit est nécessaire.
Premier jet très inspiré de https://python-uga.gricad-pages.univ-grenoble-alpes.fr/py-training-uga mais aussi d’autres ressources listées ici https://py-edu-fr.pages.heptapod.net/resources.html.
Content#
0. Preliminaries (to be done before the training)#
0.1 Setup your development environment#
Install:
Python from something like apt (Linux) or python.org (Windows)
Pipx
PDM
UV
Miniforge
Pixi
With instructions for Windows, Linux and macOS.
0.2 Clone this repository locally on your computer#
1. Appetizer with JupyterLite#
Tiny introduction without installing anything…
1.0 Quick discovery of JupyterLab#
1.1 First steps with Python#
First objects of simple types, first variables, first function calls (with
print()
)A point on function calls (with
print()
andround()
)
1.2 First usage of Python libraries (a simple Matplotlib plot)#
2. Generalities on Python#
2.1 Characteristics of the Python language#
Definition keywords and “built-in identifiers” (https://docs.python.org/3/library/builtins.html)
Notions of assignment, names, references
First name space / object space diagram
Keyword
del
Built-in functions
type()
…
Take away: dynamic languages strong thanks to tooling and testing.
2.2 Different ways to use Python#
Where/how Python code can be executed
Tools to install Python and install Python libraries and programs (basics)
2.3 Tools to develop Python code (short introduction)#
Linters, formatters and type checkers
Documentation (get and write docstrings) and comments
Testing (principle and very basic realization with
assert
)Editors / IDE:
JupyterLab
VSCode
Spyder
3. Basic pure Python#
3.1 Simple types, variables and objects#
int
,bool
,float
,complex
,NoneType
True
,False
,None
Keyword
is
,and
,or
andnot
Notions of objects and attributes (with
complex
)Built-in functions
isinstance()
,dir()
3.2 String, bytes and immutability#
First intro immutability
First sequence: indexing, slicing, lookup (keyword
in
)Notions of objects and methods
utf-8 and bytes
3.3 Conditions and if/elif/else#
Notion of block
Block
if
, keywordselif
andelse
Keywords
pass
and built-in constant... is Ellipsis
Again
isinstance()
… and notion of duck typing
3.4 Simple data structures (list and tuple, basics)#
Immutability and mutability
Keyword
in
3.5. Loops (while and for)#
Blocks
while
andfor
Keywords
in
,break
andcontinue
3.6. Exceptions and traceback#
As a user: don’t panic, read
Block
try
with keywordsexcept
andfinally
Keyword
raise
3.7. Read / write files#
Built-in function open()
and context manager with
3.8. More data structures (set and dict, basics)#
4. Structure your code and reuse existant code#
4.0 Introduction#
Notes on documentation and testing…
4.1 Functions (very basics)#
Keyword
return
4.2 Modules, packages and imports (basics)#
Keywords
import
,as
andfrom
4.3 Classes and objects (very basics)#
Only show how to define simple objects with
class
4.4 The standard library#
Small examples from (or just mention)
sys
,os/shutils
,copy
,pathlib
,argparse
,math
,re
,dataclasses
,itertools
,turtle
,functools
,unittest
,collections
Mention good alternatives outside of the standard library (Pytest, Click, …)
4.5 Test your code#
assert
Pytest
4.6 Back to functions (less basics)#
Usage of tuples for functions
Function calls: namespaces and objects “passed by references”
Different types of arguments
Global vs Local variables
Keywords
global
,nonlocal
,lambda
4.7 Generators with functions and yield (only for advanced training)#
Keyword
yield
Note
At this point, we have introduce all Python keywords, except async
and await
!
5. Use Python software#
5.1 Global installations of Python tools#
Packaging tools: specific to the OS or others, like Pipx, PDM, UV, Pixi, …
Windows specificity and native applications
5.2 Using and installing Python libraries#
Virtual environment (Python envs and others, in particular conda)
Python projects, project managers and lock files (PDM, UV, Pixi…)
5.3 Basic packaging (with testing, linting, formatting and doc) of a simple tool#
Goal: create a simple package with PDM for a simple application with dev tools like PDM, Pytest and Sphinx.
We base the presentation on a simple tool (with a CLI[1] and TUI[2]) to visualize info from Wikipedia using packages like sys, os, pathlib, argparse and runtime dependencies like Requests, Pycowsay and Textual…
Mention PyPA, PEP 517 (frontend/backend and isolated builds), PEP 518 (pyproject.toml versus setup.py)
6. Scientific Python (basics)#
6.1. Python scientific ecosystem#
6.2. Create your own working environment#
6.3. Introduction to Numpy and the Python Array API standard#
6.4. Introduction to Matplotlib and alternatives#
6.5. Introduction to Pandas and alternatives#
7. Intermediate pure Python (not needed for all students)#
7.1 Decorators#
7.2 Object Oriented Programming and magic (aka “dunder”) methods#
7.3 Generators#
7.4 Object Oriented Programming and heritage#
classmethod()
,staticmethod()
,property()
and__slots__
Abstract Base Classes (
abc
)
7.5 Gradual typing and type checkers#
7.6 Simple parallelism (threading and multiprocessing)#
Explanation about the GIL
Note about Python free-threading
Note on subinterpreters
Simple examples threading and multiprocessing
7.7 Asynchronous code and concurrency#
7.8 Define context managers#
8. More#
8.1 Introduction about performance#
Importance of profiling
Alternative Python implementations (PyPy and GraalPy)
8.2 List of useful projects#
8.3 List of web resources to find and get help#
8.4 Tools based on AI to develop with Python#
8.5 List of subjects not approached during this py-edu-fr training#
In particular metaclasses, dynamical type creation, descriptors, coroutines, weakref,
inspect
.