This script lets you color the vertices associated with any selected geometry.
# must switch to Object Mode briefly to get the new set of selected elements
# and then change the vertex_color layer
obj = bpy.context.active_object
mesh = obj.data
color_layer = mesh.vertex_colors.active
selected = set(v.index for v in obj.data.vertices if v.select)
i = 0
for poly in mesh.polygons:
for loop_index in poly.loop_indices:
vidx = mesh.loops[loop_index].vertex_index
if vidx in selected:
color_layer.data[i].color = new_color
i += 1
# set to vertex paint mode to see the result
Note: there is currently no mechanism to select verts or edges individually while in Vertex Paint mode, but you can view Vertex colors while in Edit Mode.
as an Add-on
An Add-on might already exist that does this either as a feature, or sole purpose - If so, I couldn't find it. Below you'll find the same script converted into an add-on (installation just like any other add-on).
code hosted on GitHub, or convenient download link
Spacebar -> Set VCols of any Geometry, or add a shortcut yourself.
press escape to leave the VCols unchanged, press OK to set them with the picked Color.