Change active selection from one object to another, with Python
I found the answer here.

The way you make an object active is through the overwrite of:

bpy.context.scene.objects.active 


so if you have a Cube named 'Cube', and you want to make it active, you will do:

cube = bpy.data.objects['Cube']
bpy.context.scene.objects.active = cube