PEP 526 - var annotations and the spirit of python

Antoon Pardon antoon.pardon at vub.be
Thu Jul 5 07:54:28 EDT 2018


On 05-07-18 11:59, Steven D'Aprano wrote:
> On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote:
>
>
>>> Indeed, that's often the best way, except for the redundant type hint,
>>> which makes you That Guy:
>>>
>>>     x: int = 0  # set x to the int 0
>> But you've shown in an earlier example that such a hint is *not* always
>> redundant
> But it is redundant in *that* example. Your hint is not giving any more 
> information that what the reader, or type checker, can already infer.

Yes it gives more information. Without the hint you can only interfere that
it is an int at that point. IIUC, with the hint you can interfere it is
supposed to be an int during its life time, not just at that point.

-- 
Antoon.




More information about the Python-list mailing list