[Python-3000] Adaptation and type declarations

Jim Jewett jimjjewett at gmail.com
Mon Apr 10 18:40:23 CEST 2006


Every so often Guido talks about adding optional typing to python.

Adaptation may offer the cleanest way to do this.


Turning

    def fn(a, b, c="default"): ...

into any of

    def fn(Seq a,  Index b, Text c="default"): ...
    def fn(Seq(a),  Index(b), Text(c)="default"): ...

or (wrapped version)

    def fn(Seq a,
           Index b,
           Text c="default"): ...

doesn't seem so awful.  (I'm not sure it is a net positive for
readability, but I'm also not sure it isn't.)  I read the type
information as "normally this is just an assertion, but I suppose some
protocols might *make* it true for me."

-jJ


More information about the Python-3000 mailing list