0

Lets say I have a class:

class SomeClass(SomeSuper) :
    def __init__(self) :
        #some things

But just because the class is generated from somewhere like Qt-Designer .ui to .py I dont want to touch that class, yet I want to add a built in function that is overridden from the class's super class - say:

def closeEvent(self, e)
    #some things

Is there a way I can have:

a = SomeClass()
a.closeEvent() 

where closeEvent() is outside the class somewhere else and is wired to the class?

Blue Ice
  • 7,888
  • 6
  • 32
  • 52
Temitayo
  • 802
  • 2
  • 12
  • 28

1 Answers1

1

What about monkey patching the class?

SomeClass.closeEvent = closeEvent
phyatt
  • 18,472
  • 5
  • 61
  • 80
Paulo Bu
  • 29,294
  • 6
  • 74
  • 73