[問題] 動態掛 method 進 object

看板Python作者 (張昱珩)時間10年前 (2015/05/27 16:26), 10年前編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
請問如果我想利用 decorator 動態掛 method 到某個 object 中,這樣寫會不會很怪? http://bit.ly/1cYX3dA -- http://changyuheng.github.io/ http://murmuring-on-the-air.github.io/ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.196.227 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1432715164.A.451.html ※ 編輯: changyuheng (36.224.196.227), 05/27/2015 16:26:52

05/27 16:36, , 1F
register 裡面的 Api class 根本沒必要 (函式就夠了)
05/27 16:36, 1F

05/27 16:37, , 2F
其他層面上還滿正常的, 不算太奇特的做法
05/27 16:37, 2F

05/27 16:40, , 3F
gist.github.com/uranusjr/1e824ad86f02d0a262e2
05/27 16:40, 3F

05/27 17:07, , 4F
感謝!
05/27 17:07, 4F
文章代碼(AID): #1LPN-SHH (Python)
文章代碼(AID): #1LPN-SHH (Python)