Check and Uncheck CAST ONLY option for several materials

Is it possible to check and uncheck CAST ONLY option for several materials at the same time?

for mat in bpy.context.active_object.data.materials: mat.use_cast_shadows_only = True