Python Forum
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
two modules i use
#1
what are the limits here, now?

just to be safe i am posting these two modules i wrote and use as hyperlinks

because firefox tries to just download .py links i am making these as .p.txt links so they can be looked at. but feel free to download them, if you want.  two .py links are further below.

the first one is printobject.py that has one function, print_object().  i use it to print big objects i am debugging or trying to understand.  this function outputs them in code-like form.  dictionary keys are in sorted order and padded so their values are column aligned.

the second one is pyutils.py that has many functions i regularly use. feel free to make negative (but, hopefully, constructive) comments on individual functions

printobject.py.txt

pyutils.py.txt


printobject.py

pyutils.py
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
#2
So... printobject is just a different pprint?
#3
a prettier one, IMHO.

ok, i admit i was not aware of pprint. :P   but if i was, i would not regularly use it and would still write my own. i do think my own is prettier. in version 0.1 the first feature was padding the dictionary names (keys) so the values stacked up straight.  sorting them was a later feature.

then i added the features to show string lengths and list element indexes (also helped to see how long a list was).  this was to aid debugging (making sure a long string was not too much longer than another).

a lot of what i was using this to debug was stuff that ran in cloud instances i was not logged into (logging to files and maybe later looked at).


maybe others prefer less vertical output?  :angel:
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020