1. Computing

Transitioning from 2.x to 3.0

By

2 of 6

Print as a Function
Echoing output to screen is now a function that requires one argument but that will accept up to four. The function's syntax, with default values for the optional arguments, is as follows:
 print(value, sep=' ', end='\n', file=sys.stdout) 
Examples: Basic usage:
 >>> print("Hello, World!") 
 Hello, World! 
With custom separator, line terminator, and file handle:
 >>> import sys >>> x = "World" 
 >>> print("Hello", x, sep = ", ", end="!\n", file=sys.stderr) 
 Hello, World! 
  1. About.com
  2. Computing
  3. Python
  4. Python 3.0
  5. Learn Python 3.0 - Python 3.0 Tutorials - Python 3.0 Transition Guide - Print as a Function

©2014 About.com. All rights reserved.