scripting: Modifying an object in edit mode I need to modify an object (for example rotate it) in edit mode, thanks to a script:

from math import pi
import bpy

obj = bpy.data.objects['my_object']
# go into edit mode
bpy.context.scene.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT', toggle=False)

bpy.ops.transform.rotate(value=pi/2, axis=(False, False, True))

bpy.ops.object.mode_set(mode='OBJECT', toggle=False)


but no rotation is done. If I comment out :

# go into edit mode
#bpy.context.scene.objects.active = obj
#bpy.ops.object.mode_set(mode='EDIT', toggle=False)

bpy.ops.transform.rotate(value=pi/2, axis=(False, False, True))

#bpy.ops.object.mode_set(mode='OBJECT', toggle=False)


it's working but I want a modified object in edit mode, not in object mode.

(like you do in toggling "tab", pressing "r" than the axis you want and rotate the object).
Okay, I forgot to select all the mesh after toggling to edit mode:

it's working now:

from math import pi
import bpy

obj = bpy.data.objects['my_obj']
# go into edit mode
bpy.context.scene.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.transform.rotate(value=pi/2, axis=(False, False, True))
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)