[Python-3000] Generic function PEP won't make it in time

Guido van Rossum guido at python.org
Mon Apr 23 20:43:12 CEST 2007


On 4/23/07, Phillip J. Eby <pje at telecommunity.com> wrote:
>    from overloading import overload, abstract
>
>    def foo(bar, baz):
>        """Default implementation here"""
>
>
>    @overload
>    def foo(bar:int, baz:str):
>        """Overloaded implementation for int/str here"""
>
>
>    @abstract
>    def spam(fizz):
>        """This function has no default implementation, and raises
>           a "no applicable methods" error if called..."""

(a) What's the point of having a separate keyword for this, as opposed
to just raising an exception from the body?

(b) I'm proposing an @abstractmethod, which sets its argument's
__isabstractmethod__ attribute and then returns it, otherwise
unchanged. Would this be good enough for you, or do you need @abstract
to do more? My point is, I could rename mine to @abstract so that it
would serve your purpose as well -- but only if it would serve.

>    @overload
>    def spam(fizz:list):
>        """...unless an appropriate overload is added first"""
>
> Any questions?  :)

I'd like the examples even better if they used ABCs from PEP 3119. :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list