[Python-ideas] Typecheckers: there can be only one

Nick Coghlan ncoghlan at gmail.com
Wed Sep 7 22:25:41 EDT 2016


On 8 September 2016 at 07:31, Hugh Fisher <hugo.fisher at gmail.com> wrote:
> On Wed, Sep 7, 2016 at 9:56 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>
>> Exactly - in a dynamic language like Python, running a typechecker is
>> a form of testing, rather than a necessary part of getting the code to
>> work in the first place.
>>
>
> The average programmer such as myself will expect that if I write code
> specifying the type of a variable or whatever it should *do
> something*. It's code, I wrote it, it should be interpreted.
>
> Assuming PEP 526 is implemented, suppose as a very new programmer I write
>
> foo: dict = 0
>
> (If anyone thinks even new programmers wouldn't write that, you've
> never taught an introductory programming course.)
>
> It takes very little programming experience to know that is flat out
> wrong. I cannot think of any other programming language with type
> notation where this would not be immediately flagged as an error. But
> Python will silently accept it?

It wouldn't surprise me in the least if education focused environments
like the Mu text editor and potentially even Jupyter Notebooks decide
to start running a typechecker implicitly, as many IDEs already do
that. That way, if students do add type annotations (even if they're
missing from all of the example code presented), they'll be enforced
automatically.

That's a decision to be made by instructors and development
environment developers based on their assessment of their target
audience though, it isn't something that needs to be baked into the
core runtime design.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list