Is there a built-in function to print all the current properties and values of an object?
问题 So what I\'m looking for here is something like PHP\'s print_r function. This is so I can debug my scripts by seeing what\'s the state of the object in question. 回答1: You are really mixing together two different things. Use dir(), vars() or the inspect module to get what you are interested in (I use __builtins__ as an example; you can use any object instead). >>> l = dir(__builtins__) >>> d = __builtins__.__dict__ Print that dictionary however fancy you like: >>> print l ['ArithmeticError',