0

Given python classes:

class ITextWriter:
    def write( ...

class IImageWriter:
    def write( ...

class MyFileHandler(ITextWriter, IImageWriter):
    ???

Is it possible to specify implementations for the ITextWriter and IImageWriter interfaces in MyFileHandler?

E.g. In C#, this would be:

class MyFileHandler : IImageWriter, ITextWriter
{
    void IImageWriter.write(...
    void ITextWriter.write(...
}

NB. I understand that interfaces aren't necessary in Python - they are just here to illustrate the example.

There's a question here that asks the same thing, but was unfortunately closed due to the OP not providing much detail. There is also ones on multiple-inheritance here and here, but these are specific to method-resolution-order and class names, respectively.

Community
  • 1
  • 1
c z
  • 7,726
  • 3
  • 46
  • 59

0 Answers0