Changing vertex colors through python
It seems that the way to go about it is, unintuitively, to exit edit mode into object mode in order to perform any vertex-level stuff, and then re-enter edit mode at the end of your script.



mode = bpy.context.active_object.mode
bpy.ops.object.mode_set(mode = 'OBJECT')

ob = bpy.context.active_object

for vcol in ob.data.vertex_colors:
#sample or do stuff to the vertex colors

bpy.ops.object.mode_set(mode=mode)