Change the origin of a mesh object

Hi everyone,

i was wondering about how can i change the origin of an object to a given 3d point.

Actually i use

 bpy.context.scene.cursor_location =  Vector((cursorx, cursory, 0))
 bpy.context.scene.objects.active=bpy.data.objects[obnome]
 bpy.ops.object.origin_set(type="ORIGIN_CURSOR")

But it gives some problems, and i don’t think this is a “clean” way of doing it…

So,
how can i change the origin of an object?