On Thu, Apr 1, 2021 at 11:54 AM Caleb Donovick <[email protected]> wrote:
>
> > Here, `Child` will *not* match as a sequence, even though it probably
> > should,
>
> Strong disagree, if I explicitly set `__match_seq__` to `False` in `Parent`
> I probably have a good reason for it and would absolutely expect `Child` to
> not match as a sequence.
>
How much difference is there between:
class Grandparent:
"""Not a sequence"""
class Parent(Grandparent):
"""Also not a sequence"""
class Child(Parent):
"""No sequences here"""
and this:
class Grandparent(list):
"""Is a sequence"""
class Parent(Grandparent):
"""Explicitly not a sequence"""
__match_seq__ = False
class Child(Parent):
"""Shouldn't be a sequence"""
? Either way, Parent should function as a non-sequence. But if Child
inherits from both Parent and tuple, it is most definitely a tuple,
and therefore should be a sequence.
With your proposed semantics, setting __match_seq__ to False is not
simply saying "this isn't a sequence", but it's saying "prevent this
from being a sequence". It's a stronger statement than simply undoing
the declaration that it's a sequence. There would be no way to reset
to the default state.
Brandt's proposed semantics sound complicated, but as far as I can
tell, they give sane results in all cases.
ChrisA
_______________________________________________
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/GKOUSL2CPMO7NPPTK2E7XE7LXTPDVRDJ/
Code of Conduct: http://python.org/psf/codeofconduct/