[Python-ideas] Optional static typing -- late to the party

Steven D'Aprano steve at pearwood.info
Fri Aug 22 18:15:01 CEST 2014


On Wed, Aug 20, 2014 at 05:22:45PM -0700, Ethan Furman wrote:
> On 08/20/2014 05:09 PM, Steven D'Aprano wrote:
> >On Thu, Aug 21, 2014 at 06:29:16AM +1000, Ben Finney wrote:
> >>
> >>Remember that we're talking about type annotations that are for
> >>*static code checkers* to inspect. Docstrings will certainly be
> >>available there.
> >
> >True, but runtime checks may (or may not) be a part of the code checker.
> >At least, we should not rule that out.
> 
> This proposal is not about "a code checker" but about *static* typing.
> 
> Seems to be a lot of people forgetting that *static* (at least in this 
> case), means not actually running the program -- hence, no loss of 
> docstrings.

I'm aware of that, but I'm just saying that we shouldn't rule out the 
possibility of tools which operate at runtime using those same 
annotations. If the annotations are in the docstring, then they cannot 
be used at runtime with -OO. Function annotations can be used both 
statically and dynamically, while docstring annotations cannot be relied 
on to be present at runtime.

  
-- 
Steven


More information about the Python-ideas mailing list