I have some midi files. Each midi file has some instruments. I need to know what instruments each midi file consists. I have found some python libs that can parse midi files such as mido. For example, here is the result of parsing one midi file:
I can see how many tracks in this midi file, but I don't know what instruments are playing each track. Here is midi instrument table. Does anybody know the solution?

In MIDI instruments are known as programs and each track can contain multiple instruments. Although they may not overlap (unless they use different channels). Here is Python code to display when in a track each program plays. The code assumes that the track is stored in the
trackvariable: