How do I look inside a Python object?

后端 未结 22 1702
感情败类
感情败类 2020-12-04 04:18

I\'m starting to code in various projects using Python (including Django web development and Panda3D game development).

To help me understand what\'s going on, I wo

22条回答
  •  被撕碎了的回忆
    2020-12-04 04:51

    Python has a strong set of introspection features.

    Take a look at the following built-in functions:

    • type()
    • dir()
    • id()
    • getattr()
    • hasattr()
    • globals()
    • locals()
    • callable()

    type() and dir() are particularly useful for inspecting the type of an object and its set of attributes, respectively.

提交回复
热议问题