VA <d.python.d...@indigo.re> added the comment:

The use case is a little more complex.

I have a plugin system, with abstract interfaces. Plugins can't import each 
other, but plugins should be able to allowed to depend on another plugin (using 
string codes, still no direct imports), and even subclass another plugin's 
classes (and override some of their methods).

In the sample code, A and C would be 2 plugins, and B would be a helper class 
(with string code parameters) whose purpose is to make a temporary bridge 
between A and C.
A should work standalone. C would use A's code but could reimplement some of 
A's methods. B is a internal class that has A and C at hand, and changes C's 
__bases__ to point to A.

I have been suggested other solutions, like using composition (a C instance 
would have an "a" field pointing to an A instance) to avoid inheritance 
altogether, or using the "type()" function in B.__new__ to create a custom 
class inheriting A.
None of these solutions are really satisfying because they prevent C from using 
"super(...)" to refer to A methods.
Rebinding __class__ simply does not allow to override methods at all.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32768>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to