How do I look inside a Python object?

后端 未结 22 1696
感情败类
感情败类 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:52

    I'm surprised no one's mentioned help yet!

    In [1]: def foo():
       ...:     "foo!"
       ...:
    
    In [2]: help(foo)
    Help on function foo in module __main__:
    
    foo()
        foo!
    

    Help lets you read the docstring and get an idea of what attributes a class might have, which is pretty helpful.

提交回复
热议问题