June 2017
Beginner to intermediate
274 pages
6h 49m
English
Let's look at another example (refer to the following example). Sometimes, one or more of a method's parameters don't require any processing, except assigning them to an attribute of self. Can we use decorators and annotations to make this happen automatically? Of course we can.

Let's say that if a parameter is annotated with a string, the value assigned to that parameter will be assigned to an attribute of self, using the string as the name. And if the parameter is annotated with true, the attribute will have the same name as the parameter. If there's no annotation or, if it's not a string or true, nothing will happen.
Read now
Unlock full access