2013/5/24 Ethan Furman <et...@stoneleaf.us> > On 05/23/2013 02:02 PM, Ronan Lamy wrote: > >> 2013/5/23 Łukasz Langa <luk...@langa.pl <mailto:luk...@langa.pl>> >> >> >> On 23 maj 2013, at 20:13, Éric Araujo <mer...@netwok.org <mailto: >> mer...@netwok.org>> wrote: >> >> > 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. >> >> >> This is a serious annoyance, considering that there are several places >> where a large library can reasonably define the >> implementations (i.e. with the class, with the function, or in some >> utility module). Note that in contrast with the case >> of functions in a module or methods in a class, linting tools cannot be >> expected to detect a duplication between >> functions with different names defined in different modules. >> > > What would you suggest happen in this case? >
Raise a ValueError, maybe? In that case, there needs to be a way to force the overriding when it is explicitly desired. One way would be to allow unregistering implementations: overriding is then done by unregistering the old implementation before defining the new one. This is a bit cumbersome, which IMHO is a good thing for an operation that is just as disruptive as monkey-patching a class or a module.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com