Vlastimil Brom a écrit :

Many thanks for your insights!
Just now, I am the almost the only user of this script, hence the
consequences of version mismatches etc. shouldn't (directly) affect
anyone else, fortunately.

So far so good.

However, I'd like to ask for some clarification about monkeypatching -
With "directly replace" I  meant something like the following scenario:

import difflib
....
def tweaked__chain_b(self):
    # modified code of the function __chain_b copy from Lib\difflib.py
    ...

difflib.SequenceMatcher._SequenceMatcher__chain_b = tweaked__chain_b

I thought, this would qualify as monkeypatching,

It does, indeed

but I am apparently
missing some distinction between "patching the ... code inplace"  and
"monkeypatching".

"patching source code" canonically means "physically" modifying the original source file. Monkeypatching - which can only be done in some dynamic languages - is what you're doing above, ie dynamically replacing a given feature at runtime.

By subclassing (which I am using just now in the code)

If it already works and you don't have to care too much about possible compat issues with different difflib versions, then look no further.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to