camera, bullet and environment

how can i make the camera zoom towards the player as soon as it collides with the environment?

when i shoot the bullet fly through the environment
how can i make the environment to limit the range of the bullets?

To be honest, there are many resources:

1)Camera Collision
2)Ray Sensors are best for bullets, and not small objects - small objects don’t wok well with the Physics engine.
3)Just limit the range of the ray.

i tried to make a module script (im a total noob so pls no critisism)

cont=bge.logic.getCurrentController()
obj=cont.owner
scene=bge.logic.getCurrentScene()
Cam=scene.active_camera
ray=cont.sensors[“Ray_Env”]
ray_range=ray.range[“Ray_Env”]
Zoom_Value=obj[“Zoom_Value”]
def main(controller):

if ray.positive:
    if ray_range < 0 :
        Cam.lens =(Zoom_Value-Cam.lens)*0.05
        else Cam.lens =(35.0-Cam.lens)*0.05
       else return

do u see any syntax-errors?
or tips to optimize the script?