(original) (raw)

changeset: 4920:4d6c827944c4 user: Ɓukasz Langa lukasz@langa.pl date: Fri May 31 12:31:11 2013 +0200 files: pep-0443.txt description: Explicitly state that the default implementation is registered for `object` Thanks to Gustavo Carneiro for the suggestion. diff -r 92816a630302 -r 4d6c827944c4 pep-0443.txt --- a/pep-0443.txt Fri May 31 11:34:10 2013 +0200 +++ b/pep-0443.txt Fri May 31 12:31:11 2013 +0200 @@ -134,13 +134,17 @@ Where there is no registered implementation for a specific type, its method resolution order is used to find a more generic implementation. +The original function decorated with ``@singledispatch`` is registered +for the base ``object`` type, which means it is used if no better +implementation is found. + To check which implementation will the generic function choose for a given type, use the ``dispatch()`` attribute:: >>> fun.dispatch(float)- >>> fun.dispatch(dict) - + >>> fun.dispatch(dict) # note: default implementation + To access all registered implementations, use the read-only ``registry`` attribute:: @@ -152,7 +156,7 @@ >>> fun.registry[float] >>> fun.registry[object] - + The proposed API is intentionally limited and opinionated, as to ensure it is easy to explain and use, as well as to maintain consistency with/lukasz@langa.pl