Python Forum

Full Version: Python Module to display Dictionairies for debugging
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a python application that has three threads that maintain three dictionaries with lists of work that are being processed. As a way to debug I am looking for a module that will allow me to monitor those three dictionaries as records are added or deleted. I have no experience with python GUIs so not sure what i might need.. I definitely want to keep it simple here. the displaying of the dictionaries really only needs to run in my dev environment. I can do the legwork and learn the tool, I just dont know what tool to look at.
If I had to do this I would perhaps try the ttk.Treeview wigdet in tkinter to display the dictionaries as tables.
or:
def display_dict(dictname, level=0):
    indent = " " * (4 * level)
    for key, value in dictname.items():
        if isinstance(value, dict):
            print(f'\n{indent}{key}')
            level += 1
            display_dict(value, level)
        else:
            print(f'{indent}{key}: {value}')
        if level > 0:
            level -= 1
You could use an IDE's debugging to view contents of variables
for instance VS code
VS code General Debugging
Python debug configurations in Visual Studio Code