You can use the module wnck and gtk.
For instance:
import pygtk
pygtk.require('2.0')
import gtk
import wnck
screen = wnck.screen_get_default()
while gtk.events_pending():
gtk.main_iteration(False)
for w in screen.get_windows():
name = w.get_name()
icon = w.get_icon()
...
Where name is a string and icon is a GdkPixbuf.
You can read the API documentation for libwnck at http://developer.gnome.org/libwnck/stable/WnckWindow.html, which is for C. However, for Python you only have to remove the prefix wncK_window. If the documentation say wnck_window_get_name(), then in Python would be my_window.get_name().
libwnk is specific to XWindow, hence you can not use it on MS Windows. In that case, you can use other modules that precisely helps on that. Check the answer for Get list of open windows in Python