print_object function

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.
Note: posts here are not necessarily endorsed by the community, and may represent amateur or even bad practices.

print_object function

Postby Skaperen » Sat Sep 24, 2016 4:37 am

i use this function to print objects in a nice way.
1. output is formatted like python code over multiple lines
2. dictionaries are output in key sorted order
3. dictionary keys are padded to make the same length for the same dictionary
4. strings are appended with slice code to show the length
5. types are appended in comments
6. "empty" follows the type for empty subobjects
7. the name passed in the call is shown like a key unless ...
8. if '=' is appended to the name then it is formatted like a variable being assigned.
9. indent= indents the output by that many spaces
10. file= is supported for output redirection
11. it is intended to work in both python2 and python3
12. run it as a command to run the test

since the code is large (245 lines, 9924 chars) i am making a link:
if that works better in your browser
md5sum: 8c0740e6d46c94b6fbcb32b3c3cc3899
Due to the reasons discussed here we will be moving to on October 1st, 2016. This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
Posts: 267
Joined: Tue Apr 07, 2015 9:58 am
Location: Wheeling WV USA

Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 3 guests