def f():
pass
async def af():
pass
class C:
@staticmethod
def s():
pass
@classmethod
def c(cls):
pass
def i(self):
pass
if __name__ == "__main__":
print(callable("x")) # False
print(callable(None)) # False
print(callable(lambda x: x + 1)) # True
print(callable(f)) # True
print(callable(af)) # True
print(callable(C.s)) # True
print(callable(C.c)) # True
print(callable(C.__init__)) # True
print(callable(C().i)) # True
print(callable(C.i)) # True
More than 1 year has passed since last update.
Python: コール可能なオブジェクト(関数とか)かチェックする
Last updated at Posted at 2022-03-22
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme