next up previous contents
Next: Formatting Strings Up: Input and Output Previous: Input and Output   Contents


The print command

The fastest way to print the value of an object in python is with the print command. You provide the command with a comma separated list of objects, and it displays them with spaces between each object, and a newline added at the end. The newline can be supressed by terminating the print command with a comma. The print command is capable of producing a printed representation of any type of python object, but does not provide much control over the appearance of the output. Thus, it's ideal for quick interactive jobs or short programs where the appearance of the output is not critical.

For more control over the appearance of the output, you can first format the object you wish to print (Section 5.2); to direct output to a file, see Section 5.4



Phil Spector 2003-11-12