This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author VA
Recipients VA, gvanrossum, ncoghlan, r.david.murray, serhiy.storchaka
Date 2018-02-06.08:13:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517904805.76.0.467229070634.issue32768@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-02-06 08:13:25VAsetrecipients: + VA, gvanrossum, ncoghlan, r.david.murray, serhiy.storchaka
2018-02-06 08:13:25VAsetmessageid: <1517904805.76.0.467229070634.issue32768@psf.upfronthosting.co.za>
2018-02-06 08:13:25VAlinkissue32768 messages
2018-02-06 08:13:25VAcreate