In your case, you can't easily intercept the output of MixedIntegerLinearProgram.show(). str(p) will return a string representation (rather than printing it) of your MIP, which you can write to a file.