Incoherence in the blender API for modes?

Hello, when i was trying to switch from a mode to another when coding.
don’t have the same names as

in the case of edit mode its ‘EDIT_MESH’ for bpy.context.mode and ‘EDIT’ in the operator
same for every other modes … ‘VERTEX_PAINT’ for one, ‘PAINT_VERTEX’ fot the other … every paint modes are reversed… onlyh object and sculpt are the same

this is quite minimal but well the api will be stuck in a few days, it may be the right time or never to change this incoherency? if it is one?

Well, I can see why it’s annoying that there are such differences, but it’s not a real inconsistency. The name of the current mode and the values used for the mode parameter of the mode_set() operator are two independent things. There is also a distinction between the mode of the context (=scene?) and the context object:

  • mode_set(mode='EDIT') will enter the edit mode of the active object, regardless of its type
  • bpy.context.active_object.mode will then be EDIT
  • the global bpy.context.mode depends on the object type. It is EDIT_MESH for a mesh object but EDIT_CURVE for a curve object and so on