Ok, so it turns out that actually switching windows is very easy.
#!/usr/bin/env python
# This code will focus the window with integer id 67108870
# Tips: you can get that with xwininfo -int
# wnck is used for window management
import wnck
# time is needed because wnck requires it
import time
# Get information about windows, workspaces, etc from the X server
wnck.screen_get_default()
# 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
the_win.activate(int(time.time())
I'll improve on this answer as I learn.