Ok, so it turns out that actually switching windows is very easy.
# This code will focus the window with integer id 67108870
# Tips: you can get that with xwininfo -int
# wnck is used for window management
# time is needed because wnck requires it
# Get information about windows, workspaces, etc from the X server
# Get a reference to the window we want to focus
# by providing an integer xid
the_win = wnck.window_get(67108870)
# activate the window, providing an int timestamp
I'll improve on this answer as I learn.