simple print is not working..

Paul Osman paul at eval.ca
Wed May 24 21:50:07 CEST 2006


On 24-May-06, at 3:41 PM, lahirister at gmail.com wrote:

> What is wrong with this script?
>
> #!/usr/bin/python
> fsfile = open('/tmp/fs_info.al', 'r')
> for line in fsfiles.readlines():
> print line
> fsfile.close()
>
>
> #./get_fs_info.py
>   File "./get_fs_info.py", line 4
>     print line
>         ^
> SyntaxError: invalid syntax
>
>
> Any ideas?
>
> Thanks
> AL

Well first, you have to indent properly :) Assuming you did that and  
the copy & paste just removed it, you're also creating a variable  
called fsfile, then trying to call the readlines() method on an  
object called fsfiles... that'll cause a problem.

Cheers,

--
Paul Osman
http://www.eval.ca



More information about the Python-list mailing list