print in Python 2


print is one of the keywords that changed between Python 2 and Python 3. In Python 2 it does not need parentheses, in Python 3 it is a function and it needs to have parentheses.

examples/basics/print.py
print "hello"
print "world"
print "Foo", "Bar"

hello
world
Foo Bar


examples/basics/print_no_newline.py
print "hello",
print "world"
print "Foo", "Bar"

hello world
Foo Bar

No newline, but a space is added at the end of the output and between values.


examples/basics/write.py
import sys

sys.stdout.write("hello")
sys.stdout.write("world")

helloworld

write takes exactly one parameter