[Python-ideas] Delay evaluation of annotations

David Mertz mertz at gnosis.cx
Thu Sep 22 16:09:24 EDT 2016


Doh!

Yes, of course 'self' is only a scoped name within the body of the method,
not in the signature.

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

>
> On Thu, Sep 22, 2016 at 3:58 PM, David Mertz <mertz at gnosis.cx> wrote:
>
>> It's more verbose, but you can also spell it now as:
>>
>> class A:
>>     def __add__(self, other: type(self)) -> type(self): ...
>>
>
> No, you can't:
>
> >>> class A:
> ...     def __add__(self, other: type(self)) -> type(self): ...
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in A
> NameError: name 'self' is not defined
>



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160922/ba0c3445/attachment.html>


More information about the Python-ideas mailing list