That's weird. It crashes Blender when I try to recheck centers
valuues in the console after edit mode switch. Must be some bug in the Blenders Python API. You could deselect everything without switching to edit mode. This seems to work:
import bpy
objd = bpy.context.object.data
centers = [p.center for p in obj.datad.polygons]
for vx in obj.data.vertices:
[v for v in vd.selectvertices] =+ False
[p for p in obj.datad.polygons:
polygons] p.select+ =[e False
for e in obj.datad.edgesedges]:
ex.select = False
print(centers)