Re: [問題] 請教一個很蠢的問題@@

看板Python作者 (十年~)時間12年前 (2013/07/09 12:25), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串2/2 (看更多)
有個 module 叫 types,內建的 type/class 都放在這個 module 裡,包括 old-style class 的共通型別(types.ClassType),old-style object 的共通 型別 types.InstanceType。 當你想要某種 builtin 型別的 type object reference,你沒有辦法直接寫出 type literal(比如你例中的 function type),記得來這個 module 找。 def statement 執行後產生的 function object 是 types.FunctionType 的 instance。 def foo(): pass isinstance(foo, types.FunctionType) // True type(foo) is types.FunctionType // True foo.__class__ is types.FunctionType // True -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.173.253.133 ※ 編輯: sbrhsieh 來自: 1.173.253.133 (07/09 20:27)

07/09 20:30, , 1F
抱歉,我 OP 了
07/09 20:30, 1F

07/09 23:07, , 2F
長知識!
07/09 23:07, 2F

07/10 03:41, , 3F
講的很清楚呀
07/10 03:41, 3F
文章代碼(AID): #1Ht053NQ (Python)
文章代碼(AID): #1Ht053NQ (Python)