Syntax problem - cannot solve it by myself

Thomas Jollans thomas at jollans.com
Tue Jun 8 18:25:01 EDT 2010


On 06/09/2010 12:04 AM, Deadly Dirk wrote:
> On Tue, 08 Jun 2010 21:44:18 +0000, Deadly Dirk wrote:
>
>   
>> I am a total beginner with Python. I am reading a book ("The Quick
>> Python Book", 2nd edition, by Vernon Ceder) which tells me that print
>> function takes end="" argument not to print newline character. I tried
>> and here is what happens:
>>
>>     
>>>>> print(x)
>>>>>           
>> abc
>>     
>>>>> print(x,end="")
>>>>>           
>>   File "<stdin>", line 1
>>     print(x,end="")
>>                ^
>> SyntaxError: invalid syntax
>>     
>>>>>
>>>>>           
>> What does the error message mean? I am using Python 2.6.5 on Ubuntu
>> 9.10.
>>     
>
> I figured it out. What I need is the following:
>
> "from __future__ import print_function" at the top of my script.
>
>   
Yes, that will work, but you should really install Python 3.1 (it's in
ubuntu, as others have said!) because you will almost certainly hit into
other snags. Not as obvious as this one, but they are there. You can
work around all of them, of course, in one way or another...
>
>   




More information about the Python-list mailing list