Python function callable

Source: Internet
Author: User

Callable (object)

英文说明: Check whether object is callable. If return true,object still may fail, but if return false, calling object Ojbect will never succeed.

Note : A class or function can be called directly (because the call method is already defaulted), and the instance in the class must have the __call__ () method to be called.

version : This function is available in the python2.x version. However, it was removed in the python3.0 version and was re-added in the later version of python3.2.

code example:

1>>>Callable (0)2 False3 4>>> Callable ("mystring")5 False6 7>>>defaaa ():8       Pass9>>>Callable (AAA)Ten True One  A>>>classA: -...defmethod (self): -...return0 the ... .. ->>>callable (A) - True ->>> A =A () +>>>callable (a) - False +  A>>>classB: at...def __call__(self): -...return0 ->>>callable (B) - True ->>> B =B () ->>>callable (b) inTrue

Python function callable

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.