Автор: Leonardo Giordani
Издательство: Leanpub
Год: 2022-09-17
Язык: английский
Формат: pdf (true), epub
Размер: 16.7 MB
This short book will tell you all you need to know to understand first-class citizenship in Python, which is the gateway to grasp how decorators work and how functional programming can supercharge your code.
The book contains three simple lessons, "First-class functions", "Nested functions", and "Factories", each one with some exercises and solutions. It also contains a section on "Functions and objects" and "Higher-order objects" where I discuss in detail how the concepts learned in the three lessons apply to classes and instances.
One of the most important concepts that you can find in Python (as in other languages like jаvascript, Ruby, and Scala, just to name some of the most important ones) is that of first-class citizenship. In this book I will discuss what first-class means and how knowing such a concept can benefit your code.
The starting point is a very simple question. We know that we can assign values to variables and pass values to functions. But are functions valid “values” as well? Can we use them as we use integers or lists?
The answer is yes, and this feature is granted by the first-class citizenship of functions, or, if you prefer, by high-order functions. Languages that implement such a concept offer an amazing level of power to the programmer, and in this book I will explain it through simple examples and exercises.
Скачать First-class objects in Python : Higher-order functions, wrappers, and factories