Re: [問題] decorator class in a class

看板Python作者 (nahgnimiast)時間1年前 (2022/11/19 20:39), 1年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/5 (看更多)
多謝版友解釋,原T1 decorator產生出來的是class 結果跟下面差不多,因為func不是function,所以 不會變成method,所以也就不會自動帶入self. ============================ class T1(object): pass class A(object): def f(self): pass print(type(f)) # <class 'function'> func = T1() print(type(func)) # <class '__main__.T1'> a = A() print(type(a.f)) # <class 'method'> print(type(a.func)) # <class '__main__.T1'> ============================ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.136.103.39 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1668861581.A.07B.html ※ 編輯: tsaiminghan (220.136.103.39 臺灣), 11/19/2022 20:44:44
文章代碼(AID): #1ZUCwD1x (Python)
文章代碼(AID): #1ZUCwD1x (Python)