2020-12-16から1日間の記事一覧

関数かどうかの型判定

オブジェクトが関数かどうかの判定方法は2通り。・isinstance() で判定する場合は、types の FunctionType で判定 import types f = lambda x:x+1 print( isinstance(f, types.FunctionType) ) # True ・callable() で判定、(呼び出せるかという文字通りの…