Blender 2.8 API, python, set active object
Use the view_layer
Set ViewLayer.active to any object in view layer or None
context.view_layer.objects.active = ob

Note selecting has also changed from ob.select = True to
ob.select_set(True)

which together will emulate the general case  UI state of having the context object  both active and selected.