Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import jsonpickle # pip install jsonpickle
- import json
- def pprint_obj(obj, max_depth=None):
- """
- Pretty print all attributes of an object recursively.
- Arguments:
- obj (object): object whose attributes are to be printed
- max_depth (int, optional): maximum recursion depth
- """
- serialized = jsonpickle.encode(obj, max_depth=max_depth)
- return json.dumps(json.loads(serialized), indent=4)
Add Comment
Please, Sign In to add comment