import types
class SomeClass(object):
def __init__(self, x):
self.x = x
def some_method(self, y):
print("Original method", self.x + y)
# creates instance
instance = SomeClass(1)
# test instance's method
instance.some_method(1)
>>> Original method 2
# The method to patch
def new_method(self, y):
print("New method", self.x * y)
# monkeypatch using types.MethodType()
instance.some_method = types.MethodType(new_method, instance)
# test patched method
instance.some_method(10)
>>> New method 10
Wednesday, April 26, 2017
Monkey patch an instance method in Python3
Wednesday, February 22, 2017
Change theme for the embedded terminal in gedit
The embedded terminal in gedit fetchs its theme from gnome-terminal. So that program must be first installed, then when it is configurated with a given profile theme, the same settings are used by gedit.
Wednesday, January 18, 2017
Update flash plugin for Opera
Worked for Opera version 42.0.2393.137
- Download plugin from http://get.adobe.com/flashplayer/. Get the .tar.gz version
- Unpack the contents in /usr/lib/adobe-flashplugin
- Restart Opera
Subscribe to:
Posts (Atom)