Search code examples
pythonface-recognitionopencv

I want to change a method in a code I imported using 'import cv2'


I imported cv2 and there is a function that I want to change (the predict function). I tried to see the code of cv2 in my computer but I couldn't see the code - hence I couldn't change it... Do you know how can I alter an imported code?


Solution

  • Functions in python are objects so you can replace variable representing function and override it e.g

    import foo
    
    def my_function():
         # do something
         pass
    
    foo.function = my_function