PEP 3107 and stronger typing (note: probably a newbie question)

Alex Martelli aleax at mac.com
Thu Jun 28 01:53:25 EDT 2007


John Nagle <nagle at animats.com> wrote:

> PEP 3107 is static typing without enforcement, which is not a good thing.

Wrong: PEP3107 is a syntax for adding arbitrary metadata annotations (so
that said annotations don't get squished where they don't belong, such
as decorators or docstrings, as they used to be in 2.*).  The PEP itself
offers a good example that should be vastly sufficient to destroy the
"is static typing" notion:

def compile(source: "something compilable",
                   filename: "where the compilable thing comes from",
                   mode: "is this a single statement or a suite?"): 

how do you get from that example to "PEP 3107 is static typing"?  What
an absurd, illogical leap.  Here, it's being used to provide
"per-argument docstrings" which a pydoc-like system could access as
compile.func_annotation['source'] and the like, and format as it likes
best.  Type annotations (not necessarily for checking -- third party
libraries are free to provide completely different semantics, such as
adaptation) is another possible use, and Pythonistas' creativity may
well supply many, many others.


Alex



More information about the Python-list mailing list