When you perform an action on an object in the Maya user interface, you’re using Maya commands to change the attributes of selected objects. You can use the same Maya commands explicitly to edit the attributes of objects in the scene.
Some Maya commands take an edit flag that allows you to make changes to the attributes of an object. The edit flag is used in conjunction with other flags to specify which attributes to change.
To edit the attributes of an existing object
testVarName=cmds.torus(r=1, axis=(0,1,0) )
The axis flag specifies the initial orientation of the torus. Geometry creation commands return the name of the created object, so you can easily refer to the object by storing the name of the object as a variable.
cmds.select(deselect=True)
cmds.torus(testVarName,edit=True, hr=0.4)
When the edit flag is set to True, the command is put in edit mode. When in edit mode, all flags within the brackets of the command now change the attributes of the specified object.