Python is DOOMED! Again!

Steven D'Aprano steve+comp.lang.python at
Fri Jan 23 05:23:36 CET 2015

Rick Johnson wrote:

> The solution is move the type
> hinting syntax completely out of the source file and into
> another file -- think of it as a "Python Type Hinting Header
> File".

The 1970s called, they want their bad ideas back.

I can do no better than to quote from the Go FAQs:

    Dependency management is a big part of software development 
    today but the “header files” of languages in the C tradition 
    are antithetical to clean dependency analysis—and fast 

Things that go together should appear together. Imagine a language where you
declared the function name in one file, the function parameters in a second
file, any default values in a third file, and the function body in a fourth
file. Ridiculous. Ideally, all these things should be found together,
preferably close enough for the reader to take it all in at a glance
(although some function bodies may be too large).

There may be times where splitting related things are unavoidable, but they
should be a last resort, only to be used when any other solution is

We know from Pascal and other languages that declaring types in the
parameter list works well and is very readable:

function calc(a: Real, b: Real): Integer;

We also know from Pascal that separating the declaration from the value
doesn't work so well:

function calc(a: Real, b: Real): Integer;
    x: Integer;
    y: Real;
    z: array[1...100] of Something;
    {code goes here}
    {possibly a lot of it}
    {and finally we get to this}
    x = some_function(a, 2*b+1);  {what's the type of x again?}


More information about the Python-list mailing list