I want to make minor changes (~10 lines, including editing and deleting the existing lines, and adding new lines) in the middle of a long function (~200 lines) offered by an installed pypi package.
For example:
def func(*args, **kwargs)
... # other lines remain unchanged
some lines which I want to edit
... # other lines remain unchanged
AFAIK, the decorators only add code in the beginning/end of a function, and inheritance is a basic solution but it may need a lot of unnecessary copying since I only want to change a relativaly small amount of code. I cannot directly editing the package either since the package is read-only for me and IMHO it is an inelegant solution.
So is there any simple and elegant solutions (i.e., implemented with small amount of code and good readability) to achieve this goal?