469,323 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

simple print is not working..

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

May 24 '06 #1
3 1925

lahiris...@gmail.com wrote:

Sorry typo: Script is like this:

#!/usr/bin/python
fsfile = open('/tmp/fs_info.al', 'r')
for line in fsfile.readlines():
print line
fsfile.close()

*not* fsfiles as I typed in original post.
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


May 24 '06 #2
la********@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()

Did you cut and paste that code? I see a couple typos

First, on the line

for line in fsfiles.readlines():

There's an extra s in fsfile

Secondly, the line:

print line

should have an indentation to denote that its the block of code that the
for loop will execute on.

..c

--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software

May 24 '06 #3
On 24-May-06, at 3:41 PM, la********@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
May 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.