specify types in method calls

Gerrit Holl gerrit at nl.linux.org
Sun Feb 1 09:49:53 EST 2004


Uwe Mayer wrote:
> 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?

No, it isn't.

> Or might that be possible in future versions of Python?

Who knows :-). But personally, I don't think it's very likely, because
it's syntax sugar for something that is, I believe, not very common.
(I think it's not very Pythonic, but I can't explain why)

Gerrit.

-- 
19. If he hold the slaves in his house, and they are caught there, he
shall be put to death.
          -- 1780 BC, Hammurabi, Code of Law
-- 
PrePEP: Builtin path type
    http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/




More information about the Python-list mailing list