New submission from Antoine Pitrou: singledispatch currently doesn't defend against unwanted redefinition of an existing specialization, e.g.:
>>> def f(x): return "default" ... >>> f = functools.singledispatch(f) >>> @f.register(int) ... def _(x): return "1" ... >>> @f.register(int) ... def _(x): return "2" ... >>> f(42) '2' This can be annoying when used as an extension mechanism. It would be nice if at least an option in the singledispatch() constructor could prevent this. ---------- components: Library (Lib) messages: 246493 nosy: lukasz.langa, ncoghlan, pitrou, rhettinger priority: normal severity: normal status: open title: forbid redefinition of specializations in singledispatch type: enhancement versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24597> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com