specify types in method calls

John Roth newsgroups at jhrothjr.com
Sun Feb 1 21:13:05 CET 2004

"Uwe Mayer" <merkosh at hadiko.de> wrote in message
news:bvj3bo$4ib$1 at news.rz.uni-karlsruhe.de...
> Hi,
> sometimes I'd like to be able to specify that a parameter to a method call
> should be of a specific instance. I can do that using the isinstance()
> buildin in the body of the method.
> Is there also a way of specifying this in the method definition, i.e.
> class A(object):
>     def foo( name : B ):
>         ...
> which then would be equivalent to i.e.
> class A(object):
>     def foo( name ):
>         assert isinstance( name, B )
>         ....
> Is anything like that already available? Or might that be possible in
> versions of Python?

It's certainly not standard Python. I believe there are several
different projects that have implemented some form of type

The other question is more interesting. At one point there was a
types sig that kind of meandered along without producing any

The advent of TDD (test driven development) has shown that
static typing does not show as much benefit as its proponents
claim. There are even some people (definitely in the minority,
I think) that say that the cost is more than the remaining benefit.

I think that the Python developers would be quite receptive
to proposals in that direction as long as they didn't change
the essential nature of Python. That seems to be remarkably
hard to do. There is some work being done in that direction
in the PyPy project, and the type inference mechanism in
Bycicle Repair Man seems to fall between "less than one
would hope" and "more than one would have thought possible".

John Roth

> Ciao
> Uwe

More information about the Python-list mailing list