Would you like to find a PyMEL version? Or an object oriented way of doing this? xform(obj, cp=1)
is within PyMEL. However the object oriented method to produce the same result is quite similar to theodox's response in which you would do the following:
obj.setScalePivot(obj.c.get())
obj.setRotatePivot(obj.c.get())
Centering an objects pivot is based on the center of the bounding box. obj.c.get
will return to you just that. Just plug that into the methods above.