Advanced Python Tutorial

Advanced Programming

Difficult Path in the Mountains This section of our tutorial has Python topics that are too difficult for beginners. This is also reflected in our image. The trail requires experience and beginners with insufficient experience could easily get dizzy. Those who have successfully completed our beginner's tutorial or who have acquired sufficient Python experience elsewhere should not have any problems. As everywhere in our tutorial, we introduce the topics as gently as possible.

Online Course

You will find a complete introduction into Python in our online tutorial:

Further Topics


September 2020:
I have corrected some typos in the chapter "Currying with Python". Furthermore I improved the explanations and the code examples! Thanks a lot Larry for your hints! (Bernd)

September 2020:
In my new article "Encoding Text for Machine Learning", I show how texts, like newspaper articles, books or the like, can be converted into numerical values. You need this conversion if you want to edit natural-language texts with neural networks. This is done with the help of the bag-of-words method. I also added a chapter in which I present some interesting text classification examples: "Natural Language Processing: Examples" (Bernd)

September 2020:
One of the most visited chapters of my Pyhton tutorial has the title Recursion and Recursive Functions. Have you ever heard about tribonacci, tetranacci, or pentranacci numbers? Most probably not. I haven't known them until this day. (Bernd)

August 2020:
I have improved the tutorial on functions. A smoother introduction, i.e. the call behavior and the parameter transfer are now introduced in easy-to-understand diagrams. Furthermore a lot of additional exercises with solutions round off the topics. Concerning Machine Learning: I added a new chapter on metrics (precision, accuracy, recall, f1-score)(Bernd)

August 2020:
Today I finally took the Python2 tutorial offline. Python2 should finally be history. I also reorganized the existing content. Up to now there was an "Advanced" rubric, which did not provide actual Python topics but applied Python programming. I have renamed it to Applications. I have also added a new section "Advanced". This time with advanced Python topics. Object orientation received a section of its own now. (Bernd)

June 2020:
I added three new chapters in the section "Machine Learning": Finally, I added a proper introduction chapter, "Representation and Visualization of Data" and "Train and Test Sets" (Bernd)

June 2020:
We are proud to present a new Turkish sibling of our website. Thanks to the work of Melisa Atay and Barbaros Akkurt.

June 2020:
I (Bernd) revised the chapter "Python Iterators and Generators"

May 2020:
Bernd changed the chapter on "Magic Methods and Operator Overloading". He added further examples of the __call__ method and sharpened the explanations a bit more.

April 2020:
Great news: The listings in the Python tutorial are getting more colorful. Melisa Atay works hard to turn the existing html files into Jupyter Notebooks, which get automatically transformed into html. This way the code listings get syntax highlighting. She also checks the tests and examples by doing this.

February 2020:
Bernd Klein finally finished two new chapters of my machine learning tutorial:

November 2019:
After having worked so much on Numpy, Matplotlib and Pandas, I (Bernd) concentrated on pure Python. I continued the journey into the the depth of properties. You can join me: "Deeper into Properties" One step further: "Descriptors"

October 2019:
I added a new chapter to the Pandas Tutorial: Replacing Values in DataFrames and Series

September 2019:
I reshaped most of the chapters of my Matplotlib Tutorial:

August 2019:
It was long overdue. Finally we have a chapter on pytest

Juli 2019:
I wrote a new chapter with an extensive example of multiple inheritance in Bursa and Istanbul and did the final touches on a train from Geneva to Zurich. The underlying ideas have arisen while giving Python courses in various locations. The examples were nearly finished as well. All I did in Turkey was writing the explanatory text.

June 2019:
The Chapter on Inheritance has been nearly completely rewritten. Instead of using the old and boring "employee" and "person" classes, we are now using the Robot, which we have also used in our Introduction into OOP. You will meet the robot Marvin and his new friends "James" and "Dr. Frankenstein"!

April 2018:
A completely new chapter An Extensive Example for Sets was added to our tutorial. This chapter is supplementing the chapter Sets and Frozensets

October 2017:
In our chapter on Polynomials we demonstrate how easily and beautifully a class for the creation and manipulation of polynomial functions can be written in Python.

January - March 2017:
We extended our chapters on Generators and Decorators

May 2016:
New chapter on Decorators. In combination with our chapter on Memoisation and Decorators it belongs to the most extensive treatisises on the topic of decoration à la Python!

December - March 2016:
We wrote four chapters dealing with abstract classes as a tutorial on Metaclasses: August 2015:
We added a chapter on Slots and another about the difference between type and classes.

July 2014:
An introduction into using database interfaces in Python for SQL, MySQL and SQLite

March 2014:
We are currently completely revising the chapter on object oriented programming. It's more or less complete rewrite. The old version dealing with OOP can still be accessed, though we recommend to work through the new ones.
The topic now comprises five instead of previously only one chapter:

Our next Training Courses

Our next open Python classes with Bernd Klein, the author of this website:


Python Intensive Course:
    21st of Aug - 25th of Aug , 2019
Python Course: Level II:
    7th of Nov - 11st of Nov , 2019


Python Course for Data Analysis and Machine Learning:
    10th of Aug - 14th of Aug , 2020
    31st of Aug - 4th of Sep , 2020
Python Intensive Course:
    14th of Dec - 18th of Dec , 2020
Python Text Processing and Computer Linguistics Course:
    14th of Dec - 18th of Dec , 2020


Python Intensive Course:
    16th of Nov - 20th of Nov , 2020

Lake Constance / Zurich:

Python Intensive Course:
    7th of Sep - 11st of Sep , 2020
    28th of Sep - 2nd of Oct , 2020
    16th of Nov - 20th of Nov , 2020
Python Course for Data Analysis and Machine Learning:
    10th of Aug - 14th of Aug , 2020
    31st of Aug - 4th of Sep , 2020

Munich / München:

Python Intensive Course:
    15th of Jun - 19th of Jun , 2020


Python Course: Level II:
    2nd of Dec - 6th of Dec , 2019


Python Course for Data Analysis and Machine Learning:
    31st of Aug - 4th of Sep , 2020

A Course is not a Course

The question is ambiguous. First we want to explain, why this website is called "A Python Course". This website is seen all over the world and the expression "course" has varying meanings in the English speaking world. Both in the United States and Canada, a course is a teaching unit, which might last e.g. one academic term. The students normally get a grade or some academic credit for attending the course, usually after having passed an exam.

In the United Kingdom and Australia the term "course" usually defines the complete programme of studies required to complete a major or a study path leading to a university degree. The word "unit" is used in the UK to refer to an academic course in the North American sense.

On the one hand, we had the US and Canadian sense in mind: Our Python is one teaching unit and when you have successfully passed it, you are capable of programming in Python. On the other hand, we had the original meaning of the word in mind: A "course of instruction" as it might be used in book titles like "A Course in Programming Python".