Python Forum
Could I override a fully implemented method
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could I override a fully implemented method
#1
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
Reply
#2
I would think so. But if you've got the code, why don't you run it and see if it works?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
What was I thinking?
I tried and it worked
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  DF.groupby(col).min works, mean gets a "not implemented" error samgardner5 3 481 Feb-29-2024, 06:13 PM
Last Post: deanhystad
Brick Have I implemented this function correctly? naggafin 4 2,346 May-22-2022, 02:52 AM
Last Post: stevendaprano
  python update binary object (override delivered Object properties) pierre38 4 1,768 May-19-2022, 07:52 AM
Last Post: pierre38
  dict class override: how access parent values? Andrey 1 1,634 Mar-06-2022, 10:49 PM
Last Post: deanhystad
  Due to MDLable ID does not have get attribute how to override on this jayyu 0 2,832 Dec-20-2021, 10:38 AM
Last Post: jayyu
  Override a library function that is not in __all__ Weird 7 3,288 Aug-23-2021, 05:03 PM
Last Post: Larz60+
  NotImplementedError: pseudo-class is not implemented - how to Update Python to solve apollo 1 3,090 May-16-2021, 08:03 AM
Last Post: buran
  How to fully uninstall Python from Windows? Winfried 6 10,556 May-27-2020, 10:16 PM
Last Post: snippsat
  Merge dicts without override chisox721 4 3,237 Jul-20-2019, 01:45 AM
Last Post: chisox721
  How can we override decorator? bhojendra 2 9,370 May-12-2019, 11:15 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020