Skip to content
Advertisement

Tag: pretty-print

Adding n after every element in an XML python

I’m making an automation that takes an existing XML file, changes one of the values and overwrites the file. My main problem is that its important for me to keep the formatting of the original file and i can’t manage to do that, the new data has no line breaks and its all just a long line. My code is:

Disabling sorting mechanism in pprint output

I have big dictionary which I`m printing for viewing with prettyprint, but how I can keep formatting but kill sorting mechanism in pprint? Answer Python 3.8 or newer: Use sort_dicts=False: Python 3.7 or older: You can monkey patch the pprint module. Since the 2nd output is essentiallly randomly sorted, your output may be different from mine: Another version that is

Memory dump formatted like xxd from gdb

I’m trying to inspect a buffer which contains a binary formatted message, but also contains string data. As an example, I’m using this C code: I’d like to get a hex dump of what’s in buf, of a format similar to xxd (I don’t care if it’s an exact match, what I’m really looking for is a hex dump side

Advertisement