On 6 cze 2013, at 01:47, João Bernardo <jbvsmo@gmail.com> wrote:

I was reading the recently accepted PEP 443 and this is one of the examples:

    @fun.register(float)
    @fun.register(Decimal)
    def fun_num(arg, verbose=False):
        if verbose:
            print("Half of your number:", end=" ")
        print(arg / 2)


Wouldn't a tuple of types be more suitable?

There is barely any gain from supporting a tuple syntax, whereas it closes up ways of extending the API in the future or introducing new ways of dispatch with an analogous API.

We left it out consciously.

Last thought:
People are used with decorators returning a decorated function. This is not the case here... For some, it may be confusing at first.

fun.register() does return the decorated function. This is why the example above works. @singledispatch returns a compatible wrapper, which is analogous to what @lru_cache and countless other decorators do. Is there something I am missing here?

Thanks for your feedback!

-- 
Best regards,
Łukasz Langa

WWW: http://lukasz.langa.pl/
Twitter: @llanga
IRC: ambv on #python-dev