The Language
A bit of history
Python was conceived in 1980 and started
being implemented in 1989 by Guido van
Rossum at CWI (Netherlands), entitled
BDFL (Benevolent Dictator For Life) by the
community
Focus on code readability, providing a
syntax that allows more concepts in fewer
lines of code
Fully open-source with a extremely active
and wide community
2
A bit of history – Versions
The first main community backed version:
Python 2.0, October 16, 2000
Cycle-detecting garbage collector for
memory management
Unicode support
3
A bit of history – Versions
The first main community backed version:
Python 2.0, October 16, 2000 (In 2005)
Cycle-detecting garbage collector for
memory management
Unicode support
Python 3.0, December 3, 2008
Backwards-incompatible
Major features backported to
python 2.6 & 2.7
4
DISCLAIMER: This course will be using python 3
A bit of history – Use of python
Python is currently being used for “everything”
Large-scale servers Astronomy
working 24/7
Teaching Kids
Throw-away
scripts Machine
Databases learning
Microcontrollers
5
A bit of history – Use of python
(Some) Companies currently massively using python
6
Getting started with python
Open a terminal and type “python”
7
Getting started with python
To use an external library, you need to “import” it:
Python standard library: https://docs.python.org/3/library/index.html
8
Getting started with python
You have more interactive options, like “ipython”:
9
Getting started with python
For writing scripts, you can use any “plain” text editor:
10
Getting started with python
For writing scripts, you can use any “plain” text editor:
11
Getting started with python
Or use an IDE: (e. g. pyCharm, eclipse, VS Code, ...)
12
How python works: binaries
As it is possible (and usual) to have several “pythons” installed,
some clarifications are useful
When you enter the python console, you execute a python
binary (you may have several installed!)
13
How python works: binaries & libraries
Certain libraries may be installed only in some python environments:
14
How python works: environments
If you followed the instructions, you have installed anaconda and
created an environment named “base”
These virtual environments allow to have a clean installation of
python where all third-party packages are in the required version
Different python project may (and probably will) require different
dependencies (either different libraries, or same libraries with
different versions)
Usually, you will just need to activate the desired environments:
“source activate py38”
https://conda.io/docs/user-guide/tasks/manage-environments.html
15
How python works: environments
16
How python works: binaries & libraries
To install a library:
You may do it manually (usually not encouraged):
Download package, “compile” and install
17
How python works: binaries & libraries
To install a library:
You may do it manually (usually not encouraged):
Download package, “compile” and install
You may use a package manager such as “pip” or “conda”:
E. g. “pip install ipython-sql” or “conda install ipython-sql”
This will install all dependencies, in the version required by
the package
Unless if you are a developer of a specific package, you will
probably always use this method (or analog ones)
18
Using Jupyter notebooks
For simplicity, to follow the tutorials of this course we will be using
Jupyter notebooks
Open-source web application that allows to edit
and execute code
All code is executed locally within your python
environment (even if it is shown within your browser)
To continue, change to the directory where you have downloaded
the materials of this course and execute
jupyter basic_programming.ipynb
19