I am using django-compress for compression
. According to need I want to change on of the function开发者_StackOverflow中文版s in ..../dist-packages/compress/utils.py
. How can I override
this function.
import compress.utils
utils.compress.function_to_override = overriding_function
Monkey patch it. You'll need to do this before utils
is imported anywhere else.
Alternatively, you could create a new Python module, like this:
# fakeutils.py
from compress.utils import *
# make the following line match exactly the overridden function
def function_to_override(var1, etc1, etc2):
# your version of the function
Then import that module instead:
import fakeutils as utils
精彩评论