Python introspection type (), dir (), GetAttr (), hasattr (), Isinstance ().

Source: Internet
Author: User

Python introspection

This is also Python's awesome character.

Introspection is a program written by an object-oriented language that can know the type of an object at run time. A simple sentence is the type of object that can be obtained at run time. For example type (), dir (), GetAttr (), hasattr (), Isinstance ().

 a = [1,2,3]b = { ' A ': 1,< Span class= "pl-s" > ' B2, "C": 3}c = True< Span class= "PL-C1" >print type (a), type (b), type (c) Span class= "pl-c" ># <type ' list ' > <type ' dict ' > <type ' bool ' > print isinstance (A,list) # True               

Python introspection type (), dir (), GetAttr (), hasattr (), Isinstance ().

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: 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.