I want to unparent an object with python
Solution 1:

Assume you have an object in python obj:

Try obj.parent = None

None is a keyword refer to nothing. You assign the object parent to nothing is equivalent to remove parent.

Solution 2:

Directly modified data in object without operator can lead to some problem. You can clear the parent in your blender, and in info panel you should see the python command: bpy.ops.object.parent_clear(type='CLEAR')