Recursive type annotations

Nagy László Zsolt gandalf at
Wed Jun 8 09:31:18 EDT 2016

>>         pass
>> NameError: name 'Test' is not defined
> I think you can fix this by using a string annotation as follows:
>     class Test:
>         def test(self, child: "Test"):
>             pass
Yes, you are right. It is not directly written in the official
documentation ( ), but it
is in the PEP 0484, section "Forward references".



More information about the Python-list mailing list