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,654
  • 5
  • 31
  • 50
Temitayo
  • 762
  • 2
  • 11
  • 28

1 Answers1

1

What about monkey patching the class?

SomeClass.closeEvent = closeEvent
phyatt
  • 17,674
  • 5
  • 55
  • 73
Paulo Bu
  • 28,366
  • 6
  • 72
  • 72