disable render of all collections with python in blender 2.8 I am trying to disable all collections in the render with python in Blender 2.8

It works on top-level collections with the code below, but ignores nested collections.

import bpy
coll = bpy.context.view_layer.layer_collection
for x in bpy.context.view_layer.layer_collection.collection.children:
        x.hide_render = True


Is there a way to get all collections, regardless of hierarchy?
With recursion

As well as setting attributes on all collections in bpy.data.collections can recursively walk the children.

This will only set the property on descendants of the collection. In this case bpy.context.view_layer.layer_collection.collection

import bpy

def traverse_tree(t):
    yield t
    for child in t.children:
        yield from traverse_tree(child)

coll = bpy.context.view_layer.layer_collection.collection

for c in traverse_tree(coll):
    c.hide_render = True