A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-May/126494.html below:

[Python-Dev] PEP 443 - Single-dispatch generic functions

[Python-Dev] PEP 443 - Single-dispatch generic functions [Python-Dev] PEP 443 - Single-dispatch generic functionsÉric Araujo merwok at netwok.org
Thu May 23 23:17:47 CEST 2013
Le 23/05/2013 16:10, Łukasz Langa a écrit :
>> Does this work if the implementation function is called like the first
>> decorated function?
> No, the ``register()`` attribute returns the undecorated function which
> enables decorator stacking, as well as creating unit tests for each
> variant independently.

Perfect.  My web framework of choice uses decorators that register
things and return the function as is and I love it.  I guess the common
pattern will be to use variants of the generic function name, e.g. func
is implemented by func_int, func_str and co, which also helps debugging.

>> Making generic functions work with ABCs sounds like a requirement to me
> Yes, I will implement that.

Great!

>> Question: what happens if two functions (say in two different modules)
>> are registered for the same type?
> Last one wins. Just like with assigning names in a scope, defining methods
> in a class or overriding them in a subclass.

Works for me.

Cheers
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4