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. Fixing that problem reveals another problem: rather than read the file, it will just print something like this: <built-in method read of _io.TextIOWrapper object at 0xb7b6911c> That's because you need round brackets (parentheses) to actually call the read method, otherwise you just get the method itself. Finally we get to the error you have have reported: > but on ubuntu 12.04 LTS i get this syntax error: > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > IOError: [Errno 2] No such file or directory: 'prez.dat' That's not a syntax error. The problem is not with your code, but with the location of the file. There is no file called "prez.dat" in the current directory. Possibly you have just forgotten to create the file, or you have forgotten that Ubuntu (like all Linux operating systems) are case sensitive and "prez.dat" will not match "Prez.DAT", or the file is in the wrong directory. You may need to use the cd command to go into the directory before starting Python. Does this help solve your problem? Please feel free to ask if you have any further questions. -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor