0

I've searched around online for the answer however I was not entirely clear on the content i was readying so i figured i would post it here.

I wanted to know if the way I'm creating a class inheriting from Baker is being done correctly.

Say I have a base class:

class Baker(QtCore.QObject):

    changedProperty = QtCore.Signal()

    def __init__(self, **kwargs):
        QtCore.QObject.__init__(self)
        ...

Then I create classes based off of Baker like this:

class NormalBaker(Baker):
    def __init__(self):
        Baker.__init__(self, name='Normal Baker')
        ...

is this correct?

UPDATED

Is this snippet of code the proper way to subclass from Baker?

def __init__(self):
     Baker.__init__(self, name='Normal Baker')
Nipun Thennakoon
  • 3,586
  • 1
  • 18
  • 26
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
  • If it is correct, why the question? Why do you think it is wrong? – eyllanesc Jul 03 '18 at 20:37
  • 1
    What was this "content I was reading" that you found unclear? A few links could have made your question a lot easier to understand. – ekhumoro Jul 03 '18 at 21:29
  • I updated the question – JokerMartini Jul 04 '18 at 12:59
  • @JokerMartini *Is this snippet of code the proper way to subclass from Baker?* Yes, that's right, you're passing the father's constructor what he needs. Why the doubt? – eyllanesc Jul 04 '18 at 13:06
  • @eyllanesc Was not sure if i should be using this: super(Baker, self).__init__(*args, **kwargs) – JokerMartini Jul 04 '18 at 13:10
  • @JokerMartini There are 2 styles of calling the father, `Baker.__init__(self, name='Normal Baker')` is equivalent to `super(Baker, self).__init__(name='Normal Baker) ` in the case that only a class is inherited as is your case. – eyllanesc Jul 04 '18 at 13:16
  • 1
    @JokerMartini see this: https://stackoverflow.com/questions/576169/understanding-python-super-with-init-methods – eyllanesc Jul 04 '18 at 13:17

0 Answers0