layerlist = arcpy.mapping.ListLayers(...) if layerlist: do_something() else: handle_empty_layer_list()
I know this is an old thread, but a working snip was never posted, so here you go!
TurnOffLayer.py
_________________
import arcpy
fileName=arcpy.GetParameterAsText(0)
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr=arcpy.mapping.ListLayers(mxd, fileName)
if lyr:
if lyr[0].visible==True:
lyr[0].visible=False
arcpy.RefreshActiveView()
sys.argv[2]=True
arcpy.SetParameter(1,"True")