[Python-ideas] Delay evaluation of annotations

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Sep 22 16:48:40 EDT 2016


On Thu, Sep 22, 2016 at 4:43 PM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

>
> On Thu, Sep 22, 2016 at 4:37 PM, Alexander Belopolsky <
> alexander.belopolsky at gmail.com> wrote:
>
>> On the second thought, why can't the parser simply replace A with 'A' in
>> annotations that appear in the body of class A?  This will only break
>> somewhat pathological code that defines A before it is (re)defined by the
>> class statement.
>
>
> Then the default metaclass (type) can go over the annotations and replace
> 'A' with A that it just computed.
>

On the third thought, this entire feature can be implemented in the
metaclass by injecting A = 'A' in the dict in __prepare__.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160922/31294f8c/attachment.html>


More information about the Python-ideas mailing list