On 4/22/22 19:17, Chris Angelico wrote:
I'm unsure about the forward class. How is it different from subclassing an ABC?
They're just different objects. A subclass of an ABC is either itself
another abstract base class, which will never be instantiatable, or a
non-abstract class, which is immediately instantiatable. A
forward-declared class object is not currently instantiatable, and is
not fully defined, but will become fully defined and instantiatable
after the matching "continue class" statement.
What happens if you try to continue a non-forward class?
From the proto-PEP:
Executing a `continue class` statement with a class defined by the
`class` statement raises a `ValueError` exception.
And also:
It's expected that knowledgeable users will be able to trick Python
into executing `continue class` on the same class multiple times by
interfering with "dunder" attributes. The same tricks may also
permit users to trick Python into executing `continue class` on a
class defined by the `class` statement. This is undefined and
unsupported behavior, but Python will not prevent it.
//arry/
_______________________________________________
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/QU2HE5AAMLHU33Z5Y4EPDF46CXO7F3NF/
Code of Conduct: http://python.org/psf/codeofconduct/