Getting the file type

Hello,
I’m using python to process my tracks. I open the audio file manually, prepare the track and run a python that does some processing and exports the track into a new file.
All my audio files until now were MP3 so I assumed in my script that the extension of the new audio to export would be mp3.
Suddenly I have an m4a file so I need to enhance the script to check the input file extension so it exports an audio file of the right type.
I cannot find a way to get it - I thought the “GetInfo” message would have something but couldn’t find it.
I hope I’m clear…
Thank you in advance,
Marcelo