# a little verbose? :)
import bpy
scene_groups = bpy.data.groups
# make sure before this, that nothing is selected.
names_of_grouped_objects = []
for i in bpy.context.selectable_objects:
for group in bpy.data.groups:
for item in group.objects:
if item.name == i.name:
print("i.name", i.name, " is grouped in ", group.name)
names_of_grouped_objects.append(i.name)
# ungrouped objects
print("ungrouped objects are these")
for i in bpy.context.selectable_objects:
if i.name not in names_of_grouped_objects:
print(">>>",i.name)
bpy.data.objects[i.name].select = True