What are the advantages in using a Python class?

Classes are a mechanism to organize your code into generic, reusable peices of code. At their best they are reusable code snippets that will be used over and over again with little or no modification. The class concept was inspired by biological collections of features (attributes) and abilities (methods).

Functions are great to use when data is critical to the work being done. Classes are great when you need to represent a collection of attributes and methods that will be used repeatedly in other places.

Generally if you end up writing functions inside of functions you should consider writing a class instead. If you only have only one function in a class then better stick with just writing a function.

A good reason to move from functions to classes in your programming is to write classes using composition over inheritance.