[Tutor] code works in windows command but not ubuntu terminal

bob gailer bgailer at gmail.com
Sat Jan 25 04:28:09 CET 2014


On 1/24/2014 4:47 AM, Steven D'Aprano wrote:
> Hi Tobias, and welcome.
>
> On Thu, Jan 23, 2014 at 07:34:18PM -0700, Tobias Quezada wrote:
>> hello community,i am a newbie to python and program in general.
>> the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal.
>>
>>>>> fp=open("prez.dat","r")
>>>>> x=fp.read
>>>>> (print(x)
>> ***i used fp for file pointer.I am using windows 7 and it works
> Are you sure this is the *exact* same code you use on Windows 7? Because
> it won't read the file, it will fail with a SyntaxError due to the
> missing close bracket after the print.
This is Python 2.7.3, not 3.x. The error is due to a ( in front of the 
print statement.

And please call () parends and [] brackets, and{} braces. Saves a lot of 
confusion.



More information about the Tutor mailing list