Of the two Python code examples you found, I think the second one is clearer and likely to serve you better in your efforts to understand spectral subtraction and develop a Python script-file for your work.
The "noise_subtraction.py" script-file implements a basic power spectral subtraction method. A good paper that describes this method is: "Enhancement of speech corrupted by acoustic noise", Proceedings of the International IEEE Conference on Speech, Acoustics and Signal Processing, 208-211, 1979. Since you are student at Imperial College, you should have no problem finding this paper.
A related resource that you'll want to find is the Speech Enhancement: Theory and Practice textbook. It describes several spectral subtraction methods and includes functional Matlab script-files that demonstrate the methods. In particular is a Matlab implementation of the method described in the Berouti et al. paper.
I know you are looking specifically for Python code, but if you review the material I've suggested and are able to obtain the basic power spectral subtraction Matlab code in the Loizou textbook you'll be in a position to use the "noise_subtraction.py" code you found.
As a final note, see this site for additional papers and Matlab code on speech related processing.
I hope this helps.