Switching windows or tabs is also possible from Python code. The example below uses the selenium module and web driver.
This should work for all the supported web browsers including Chrome, Firefox, IE and all the others.
The selenium switch to window code shown below. It starts firefox, opens a webpage, then a new tab and window with different web sites.
# -*- coding: utf-8 -*-