How can I exclude a collection from rendering with Python?
Use the View Layer



From the context view layer

&gt;&gt;&gt; C.view_layer.active_layer_collection
bpy.data.scenes['Scene']...LayerCollection

&gt;&gt;&gt; C.view_layer.active_layer_collection.name
'My Leaf 0.0'

&gt;&gt;&gt; C.view_layer.active_layer_collection.exclude
False


Alternatively from scene

&gt;&gt;&gt; C.scene.view_layers['RenderLayer'].active_layer_collection
bpy.data.scenes['Scene']...LayerCollection

&gt;&gt;&gt; C.scene.view_layers['RenderLayer'].active_layer_collection.name
'My Leaf 0.0'


Related 

Change active collection