[Python-ideas] Delay evaluation of annotations

אלעזר elazarg at gmail.com
Thu Sep 22 22:05:28 EDT 2016


On Fri, Sep 23, 2016 at 4:17 AM Nick Coghlan <ncoghlan at gmail.com> wrote:
...

> As others have noted, the general idea of allowing either a
> placeholder name or the class name to refer to a suitable type
> annotation is fine, though - that would be a matter of implicitly
> injecting that name into the class namespace after calling
> __prepare__, and ensuring the compiler is aware of that behaviour,
> just as we inject __class__ as a nonlocal reference into method bodies
> that reference "super" or "__class__".
>
> Just to be sure I understand, will the following work?

class A:
    def repeat(n: int) -> List[A]: pass

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160923/dced9e1d/attachment.html>


More information about the Python-ideas mailing list