On 14.02.15 01:03, Neil Girdhar wrote: > Now the derived class knows who is asking for a copy. In the case of > defaultdict, for example, he can implement __make_me__ as follows: > > def __make_me__(self, cls, *args, **kwargs): > if cls is dict: return default_dict(self.default_factory, *args, > **kwargs) > return default_dict(*args, **kwargs) > > essentially the caller is identifying himself so that the receiver knows > how to interpret the arguments. No, my idea was that __make_me__ has the same signature in all subclasses. It takes exactly one argument and creates an instance of concrete class, so it never fails. If you want to create an instance of different class in the derived class, you should explicitly override __make_me__.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4