June 2017
Beginner to intermediate
274 pages
6h 49m
English
Calling a factory function means give me the right object for these parameters, rather than giving me a new object for these parameters. Let's take a look at an example class decorator that replaces the class object with a factory function.
For instances of this class, we'll assume that any two instances that were created with the same parameters should actually be the same object, as shown here:

In the preceding example, we used WeakValueDictionary to keep track of the existing instances of the class and what parameters that were constructed with.
This doesn't have anything to do with class decorators per se; instead, ...
Read now
Unlock full access