[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022年4月22日 19:39:38 -0700

On 4/22/2022 9:13 PM, Larry Hastings wrote:
   forward class X()
New keywords are a nuisance. And the proposed implementation seems too complex. How about a 'regular' class statement with a special marker of some sort.
Example: 'body=None'.
Either __new__ or __init__ could raise XError("Cannot instantiate until this is continued.", so no special instantiation code would needed and X could be a real class, with a special limitation.
   continue class X:
     # class body goes here
     def __init__(self, key):
       self.key = key
'continue' is already a keyword. Given that X is a real class, could implementation be
X.__dict__.update(new-body-dict)
--
Terry Jan Reedy
_______________________________________________
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/UAZ5P7N5S4OWFSVZSKK6DUEPZTQPV3GP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to