A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-February/138268.html below:

[Python-Dev] subclassing builtin data structures

[Python-Dev] subclassing builtin data structuresSerhiy Storchaka storchaka at gmail.com
Sat Feb 14 07:22:24 CET 2015
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__.

More information about the Python-Dev mailing list

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