Deselect active object with Python? 2.8 How do I deselect the active object from a selection of 2 objects with python?

And if necessary, how do I make the second object (the not active one) active once I've deselected the first one?

EDIT1: Ok I found the answer to my first question doing  that:

bpy.context.active_object.select_set(False)


But I need to make the other object the active one, without using it's name to direct the selection or anything like that.

EDIT2:

Found the answer :)

bpy.context.active_object.select_set(False)
for obj in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj
bpy.context.active_object.select_set(False)
for obj in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj