import psycopg2
conn = psycopg2.connect("dbname='testpostgis'host='localhost' user='moi'")
import psycopg2.extras
dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
dict_cur.execute("""SELECT nom,the_geom from testpoly;""")
rec = dict_cur.fetchone()
print rec['nom']
'test1'
print rec['the_geom']
'01030000000100000007000000B64939E22648B73F210C2F0B83D7E93F0399366B2021C23F5B07A42CAEA5E93FA3A3B4CC6E14D73F3164C5F9C377E63FAB25B136C9D8CE3F179603F45D89E13FD2DA533F623EB63FB4B2452B5BB4E23FA1C950507AE0AB3FA12E64C5F9C3E73FB64939E22648B73F210C2F0B83D7E93F'
dict_cur.execute("""SELECT nom,astext(the_geom) from testpoly;""")
rec2 = dict_cur.fetchone()
print rec['astext'] #puisque l'on demande la fonction Postgis AsText, on pourrait faire la même chose avec askml etc.
'POLYGON((0.09094470046083 0.807557603686636,0.141635944700461 0.80147465437788,0.360622119815668 0.702119815668203,0.240990783410138 0.548018433179723,0.086889400921659 0.584516129032258,0.054447004608295 0.742672811059908,0.09094470046083 0.807557603686636))'