[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020年2月06日 13:55:25 -0800

> It would create an exception of two rules:
I don't think these are "rules", I think they're just "the way things are".
If I'm subclassing `dict`, and I see in the docs something to the effect of:
> By default, `dict` subclasses will return `dict` objects for `|` operations. 
> To force the creation of a new instance of the subclass, users can override 
> the `copy` method. In that case, the return value from this method will be 
> used instead.
Then my life suddenly becomes a lot better, because chances are I've already 
thought to override `copy`. And if I want the "legacy" behavior, it's as simple 
as not bothering with "copy" (or, if I need to, overriding the `__or__` 
trio)... but I'm sure this is the less common case.
If we're quoting the Zen, then let's not elevate past design patterns to 
"rules". Besides, practicality beats purity. ;)
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/L5ODZ2TEEY2T53C5KB25WJPFGJAU7IIP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to