How do I select a all objects in a particular group?

I would like to select all objects that I have placed in a group named ‘gems’. I have found this operator in the doc


but I have no idea on how to target the group ‘gems’. Any ideas?

You need to select at least one object in the ‘gems’ group, then you can do:

bpy.ops.object.select_grouped(extend=True, type=‘GROUP’)

to select all the objects in the group, otherwise there is no object context for the operator.

You could also iterate over the group and select them one by one:

import bpy

for ob in['gems'].objects: = True