Are there any PEPs for typed arguments?

F. GEIGER fgeiger at datec.at
Sun Dec 2 19:39:18 CET 2001


Are there any ideas to promote these lines

def meth(a, b, c, d):
   assert type(a) == IntType
   assert type(b) == StringType
   assert isinstance(c, MyClass)
    <meth body>
   return

into something like this:

def meth(a: IntType, b: StringType, c: MyClass, d):
   <meth body>
   return

in a future version of Python?

Actually the Python interpreter would change those lines into the former
ones, i.e. it would replace the ": Type" by the appropriate assert
statements, when compiling.

No, this is not about dynamic vs. static typing (at least I think so) as
discussed so many times in the past. Everything else would remain as it is
now. This would just be an abbreviation for writing assert statements and
thus make Python code clearer (and, yes, save a few keystrokes).

Will such ideas make it into Python? And if yes, when?

Or am I the only one who does those asserts over and over again?

Cheers
Franz








More information about the Python-list mailing list