Detect two objects colliding, and write the frame number when collision happened Yes, I know it is similar to this question, but I want further explanation.

I would like to detect two objects colliding, and write the frame number if on that frame the collision happened. Collision itself can be detected using the method described in the previous link, but I don't know on which 'operation', for example, 'scale' in the linked page, should I apply that driver. 

Furthermore, I wonder I can run a simple python script for file writing, if a collision is detected using the driver method.
You can use Animation Nodes for this. We compute the distance between the two target objects, if the distance is smaller than the sum of the radii of their bounding sphere, we create a text from the current frame and if not create an empty text, we read an initially empty text block and append the result to it with a line break as separator (Though a separator of your choice can be used), then we write the output to the text block again. Now as soon as they collide, the frame will be written in a new line.