Are there any PEPs for typed arguments?
Brian Quinlan
brian at sweetapp.com
Sun Dec 2 14:08:10 EST 2001
F. GEIGER wrote:
> 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?
I think that a better question is why are you adding these asserts in
the first place?
Are you claiming that "meth" would not work correctly if I passed a
small long for "a" or that I could not use a instance that supports
__getitem__ (that always returns a length 1 string), __len__ and a few
other string methods for "b"?
So why restrict the use of compatible types?
Cheers,
Brian
More information about the Python-list
mailing list