[Python-ideas] Optional static typing -- the crossroads
Łukasz Langa
lukasz at langa.pl
Sun Aug 17 01:28:24 CEST 2014
On Aug 15, 2014, at 5:26 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Łukasz Langa wrote:
>
>> class C:
>> cls_member: str = ‘on the class’
>> def __init__(self):
>> self.obj_member: str = ‘on the instance'
>> self.cls_member = 2 # that’s the real question: type error or an instance member?
>
> I think not treating it as an error would make it hard
> to reason about the type of x.cls_member for an instance
> x of C. Its type would depend on whether del x.cls_member
> had been performed on x.
>
> Code which relied on them being different types would
> be rather confusing to a human reader too, so it's
> probably fine to discourage that.
That was my reasoning exactly. +1
--
Best regards,
Łukasz Langa
WWW: http://lukasz.langa.pl/
Twitter: @llanga
IRC: ambv on #python-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140816/f5e3e861/attachment.html>
More information about the Python-ideas
mailing list