Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> PHP also has `var_dump`. But we don't have any equivalent in python.

Maybe pprint is for you:

    from pprint import pprint
    # usage, but can do more as well and has more config stuff if needed
    pprint({'a':'b'})

 https://docs.python.org/3/library/pprint.html


`vars` as well: https://docs.python.org/3/library/functions.html#vars

Although it'd be nice if it worked with slotted classes instead of just blowing up.

Dataclasses have asdict which work on both, but it's annoying there's nothing for regular classes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: