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__.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com