[Python-ideas] Delay evaluation of annotations
Stephen J. Turnbull
turnbull.stephen.fw at u.tsukuba.ac.jp
Tue Sep 27 06:20:01 EDT 2016
Neil Girdhar writes:
> I agree that circularity should in general be avoided, but it's not always
> possible or elegant to do that. Sometimes you really need two classes to
> refer to each other. In that case, why not expose your placeholder idea to
> the user via a library?
Why not just expose it through a simple assignment?
https://mail.python.org/pipermail/python-ideas/2016-September/042563.html
Note that this also works for typechecking in PEP 484 checkers that
allow forward reference via the stringified class name. See also
https://mail.python.org/pipermail/python-ideas/2016-September/042544.html,
which would allow eliding the assignment, but pollutes the class namespace.
"Simple is better than complex."
This feature is still looking for a persuasive use that needs it, and
not something simpler.
Steve
More information about the Python-ideas
mailing list