This is called a monkey patch. In short, you can simply assign a variable holding a function:
import existingmodule
existingmodule.foo = lambda *args, **kwargs: "You fail it"
This is rarely the right answer in practice. It is much better to wrap something with your own function or provide your own implementation elsewhere or use inheritance (if the method is in the class).
, , - , ( ); , . , ; , , .