specify types in method calls

Uwe Mayer merkosh at hadiko.de
Sun Feb 1 09:44:11 EST 2004


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 future
versions of Python?

Ciao
Uwe



More information about the Python-list mailing list