How to enable ambient occlusion with python? I am trying to access the world shading settings in python.
I want to enable ambient occlusion and give it a value of 0.5.
I have tried:

bpy.types.WorldLighting.use_ambient_occlusion()


But I didn't work.
To turn Ambient Occlusion on you must set its value to True. What you are doing wrong is that you are trying to execute the function use_ambient_occlusion() which does not exist because it's variable not a function.

import bpy
bpy.context.scene.world.light_settings.use_ambient_occlusion = True  # turn AO on
bpy.context.scene.world.light_settings.ao_factor = 0.5  # set it to 0.5