scale by distance

hello, can anyone help me?

i was given this script a while back;
import bge
from math import radians

def main():

cont = bge.logic.getCurrentController()
own = cont.owner

actu = cont.actuators['Motion']

if not "rot" in own:
    own["rot"] = 0

scene = bge.logic.getCurrentScene()
target = scene.objects["Cube"]
dist = (	own.getDistanceTo(target))

rot_amount = 3 

if dist<0.4:
    if own["rot"] <180:
        own["rot"] += rot_amount
        own.applyRotation([0,0,radians(rot_amount)], 1)
    if own["rot"] >0:
        own["rot"] -= rot_amount
        own.applyRotation([0,0,radians(-rot_amount)], 1)


this script is used to rotate an object when a cube gets close to it, but now i would like it to change the scale on one axis as the cube gets close to it, can any one help with changing it to make it work. thanks