對象內的信號響應在JavaScript中,如果我有一個包含希望將信號發送到對象外部對象的方法,我可能會做這樣的事情......附加處理程序蟒蛇
function class1(arg1){
...
//something has happened - send out an alert
this.method1();
...
}
var obj1 = new class1();
//define function to respond to the request from obj1
obj1.method1 = function(){ ... }
在python中有這樣做的等價方法嗎? (python 2)。
我認爲blinker可以給你你需要的東西https://pypi.python.org/pypi/blinker – zero323
[向現有對象添加方法]的可能重複(http://stackoverflow.com/questions/972 /添加方法到現有對象) – Marcin
我不想將方法添加到對象。 – spiderplant0