[Python-3000] Adaptation and type declarations
Guido van Rossum
guido at python.org
Mon Apr 10 22:43:50 CEST 2006
On 4/10/06, Chaz. <eprparadocs at gmail.com> wrote:
> If you are going this far, why not also support a throws() modifier (or
> whatever you might call it).
>
> Right now I do something like:
>
> @throws(IOError)
> def foo(...) :
>
> as a way to indicate that foo() can throw a specific exception.
>
> I might suggest
>
> def foo(...) throws(...) :
>
> as a more integrated approach.
-1 without more (and I mean A LOT MORE) motivation. IOW unless you
write a whole PEP I'm going to ignore this proposal.
> On this direct topic because there is no type-specific polymorphism in
> Python,
What does that mean? I always think of Python as a language with
excellent support for polymorphism (due to duck typing). So you
probably are using words in a way that I don't understand (don't
worry, that happens all the time).
> I occasionally write functions that do slightly different things
> depending on the type of input. Is there an approach to say a specific
> argument can take any number of different types?
Yes, I proposed using the '|' operator to separate alternatives. E.g.
def foo(x: int|float, y: str|list[str]): ...
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list