June 2017
Beginner to intermediate
274 pages
6h 49m
English
Now we're going to take a look at something really wild. The syntax we use for defining classes is pretty generic; it could be used to represent all sorts of different data structures. So, why not use class decorators to transform class definitions into objects of various types?
By doing this, we can achieve a sort of sideways decorative programming paradigm. For our example (the one that will follow), let's say we want to connect to a sqlite database and create some tables in it if they don't already exist. We can make Python's class syntax work for us as a convenient way of expressing this idea:

We want the usage to look ...
Read now
Unlock full access