Just like MEL, you can enter Python commands in the Command Line or the Script Editor. The Command Line can only accept single line Python commands, while the Script Editor provides a method to input multiple Python commands and view the results.
The Script Editor displays a running history of executed commands and the results of commands that Maya executes. You can copy most commands from the history section of the Script Editor and paste them in the input section to execute them. However, the results of Python commands are not echoed to the Script Editor exactly like MEL.
For more information, see To set up the Script Editor.
To type a Python command in the Script Editor
import maya.cmds as cmds
You now have access to Maya commands through the maya.cmds module.
By convention throughout the documentation and the Python command reference, the maya.cmds module is renamed cmds, but you can rename the module anything you like.
In the Script Editor, the Enter (Windows) or Return (Mac OS X) key above the Shift key does not execute a command. It starts a new line so you can type several commands before executing them.
For more information, see Initializing the Maya Environment in and for Python.
cmds.polyCube()
A polygonal cube is created at the origin. This is equivalent to using the polyCube command in MEL.
The command is removed from the input section of the Script Editor after execution. The command and the result of the command is output to the upper section of the Script Editor. The results of Python commands are displayed in the Script Editor between a set of Python commenting characters (#).
You can also enter commands in the Command Line.
Show the Command Line by selecting Display > UI Elements. By default the Command Line is in MEL script entry mode. You can change the mode by clicking on the text in the lower left hand corner. To enter Python commands, the command line must be in Python mode.
To use a Maya command with positional arguments
cmds.move(1,2,3)
The polygonal cube moves to the XYZ co-ordinates 1,2,3.
The move command accepts XYZ co-ordinates as its commands arguments.
cmds.scale(2,2,2)
cmds.scale(3)
When a command is not provided with enough command arguments, the command uses the default arguments. The polygonal cube X scale is set to three, but the Y and Z scale values are set to their default argument one.
cmds.delete()