Calculating coordinates

Hello, who can help write a script Calculating coordinates and adding the difference of values. we fix the position of the object, move it and save the difference between one position and the other, and then we can add these values in another place of world space the object to move and rotate by the same degree and distance. need fix rotation and translate.
Thx.
or suggest me what’s wrong here
from pymel.core import *

class CopyOffset(object):
def init(self):
self.offs_mx = None
with window():
with verticalLayout():
button(label=‘Copy’, command=Callback(self.copy))
button(label=‘Paste’, command=Callback(self.paste))

def copy(self):
    objs = selected()
    if len(objs) > 1:
        obj_1 = objs[0]
        for i, obj in enumerate(objs[1:]):
            # self.offset_mx = obj2.getMatrix(worldSpace=True) * obj1.getMatrix(worldSpace=True).inverse() 
            setattr(self, "offset_{}_mx".format(i+1),  obj.getMatrix(worldSpace=True) * obj_1.getMatrix(worldSpace=True).inverse())

def paste(self):
    objs = selected()
    if len(objs) > 1:
        obj_1 = objs[0]
        for i, obj in enumerate(objs[1:]):
            # obj2.setMatrix(self.offset_mx*obj1.getMatrix(worldSpace=True))
            obj.setMatrix(getattr(self, "offset_{}_mx".format(i+1)) * obj_1.getMatrix(worldSpace=True))

def show():
CopyOffset()

show()