Toggle Lamp Visibility Blender Game Engine and Python
In python you can access the lamps energy attribute like this:

bpy.data.objects["Lamp"].data.energy = 0


In the game engine you can toggle the energy by this script (assumes energy value set to 1.0):

co = bge.logic.getCurrentController()
lamp = co.owner
toggle = co.sensors["space"] # space is the name of keyboard sensor

if toggle.positive:
    lamp.energy = 1 - lamp.energy