You are right it doesn't spit out a python dictionary, but that's not what the code is doing.

Its parsing the text output, since lmod didn't return a python list or dictionary or anything for what's loaded.