开发者

What is the new way of checking "callable" methods in python 3.x?

开发者 https://www.devze.com 2022-12-23 05:38 出处:网络
I was studying introspection in Python, and as I was getting through basic examples, I found out that the callable built-in function is no longer available in Python 3.1.

I was studying introspection in Python, and as I was getting through basic examples, I found out that the callable built-in function is no longer available in Python 3.1.

How c开发者_如何学Can I check if a method is callable now?

Thank you


The callable() builtin function from Py2.x was resurrected in python3.2.


if hasattr(f, "__call__"):

What's New In Python 3.0


isinstance(f, collections.Callable)
0

精彩评论

暂无评论...
验证码 换一张
取 消