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

2022年4月24日 07:21:51 -0700

On 4/24/2022 5:42 AM, Stephen J. Turnbull wrote:
What's the use case for arbitrary expressions vs. a (possibly
qualified) name? A class factory that produces forward declarations?
Do you have a use case in mind?
It's:
x.py:
------8<--------
forward class A()
------8<--------
x_impl.py
------8<--------
import X
continue class X.A:
  # class body here
------8<--------
It needs to be an expression because it's not defining a name, it referring to an existing name. You could use "from X import A" here and avoid a dotted expression, but it still needs to be an expression referring to an existing "forward class". Even if you restrict it to not having dots, it's logically an expression, not a name binding.
Eric
_______________________________________________
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/VV53MWDTYQCHBCAQGXLZ4SFCKUEHPQ2K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to