Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I used the synaptic package manager to download the following:

python(was already installed), libpython3.2, python3.2-dbg, idle-python3.2, ' python3.2- minimal(was already installed)

When I run the IDLE I type a simple line like print "some sample text"

And I get a syntax error. Can someone tell me what I'm doing wrong?

Python 3.2.3 (default, Oct 19 2012, 20:13:42) 
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>> print "some sample text"
SyntaxError: invalid syntax
>>> 
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Actually, there's nothing wrong with the package you installed, you are trying to use python 3, check the what's new page to see the differences, one of them is that:

The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105). Examples:

Old: print "The answer is", 2*2
New: print("The answer is", 2*2)

Old: print x,           # Trailing comma suppresses newline
New: print(x, end=" ")  # Appends a space instead of a newline

Old: print              # Prints a newline
New: print()            # You must call the function!

Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)

Old: print (x, y)       # prints repr((x, y))
New: print((x, y))      # Not the same as print(x, y)!
share|improve this answer
    
LOL I'm an idiot. Ty! –  Deus Deceit Nov 7 '12 at 12:05
    
@Evandro Yep, that's right. I think we just posted our answer at a time. anyway, let's leave it as it is for confirmation :) –  Achu Nov 7 '12 at 12:09
    
@Achu yeah, but since the interpreter was running fine and python gave a SyntaxError, everything seems to be working. –  Evandro Silva Nov 7 '12 at 12:12
add comment

In python 3, print is a function. You need to use it just like print("some sample text")

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.