lock object

how do you lock the dimensions of a newly created object in python ?

i need to lock only the dim - i want to be able to move or scale it at will
but not to change the relative dimensions to preserve angle for triangles

butt should be allowed in last resort to change this lock in the N- transform panel