Python Forum

Full Version: Could I override a fully implemented method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all
I have an abstract class with a mixture of abstract methods and fully implemented methods. The latter are correct for 99.9% of the derived classes. Please refer to snippets
import abc
import pprint
class connect(metaclass=abc.ABCMeta)

    def __init__(self, config):
        self._config = config:

    @abc.abstractmethod
    def message(self):
        pass

    def printconfig (self):
        config = self._config
        pprint.pprint (config)

class connectASE (connect):

    def message(self):
        config = self._config
        message = config.get('message')
        print (message)
# so far so good, but let's say that in this particular class I want
# to divert from the standard printconfig and do

    def printconfig (self):
        config = self._config
        print ("Note that this is connectASE")
        pprint.pprint (config)
would that work
I would think so. But if you've got the code, why don't you run it and see if it works?
What was I thinking?
I tried and it worked
Thanks