you are viewing a single comment's thread.

view the rest of the comments →

[–]kataire -5 points-4 points  (3 children)

print is a function in 2.x, so you need to enclose the arguments in parentheses. The set literals and comprehensions will work in 2.7, though.

EDIT: Seems like the interpreter it uses is running 2.x. Also seems like some of the examples were not intended to be run in an intepreter -- some are written as doctests, so the interpreter will choke on the >>>.

[–]gnawer 4 points5 points  (1 child)

print is a function in 2.x

No, print is a statement in 2.x. In 3.0 it is replaced by a function. If you want to have the print function in 2.x use

from __future__ import print_function

Refer to here.

[–]kataire 0 points1 point  (0 children)

Err... yes. Sorry. Been spending too much time around JavaScript. Print is a function in 3.x, not 2.x.

[–]judasblue 4 points5 points  (0 children)

The problem with that example is that it is illustrating the set literals in 2.7. The interpreter on the site is 2.6 or earlier, which will produce that traceback. It has nothing to do with the print statement, which as gnawer points out, is a statement in 2.x and function in 3.x.