473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 1971

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gelo Ilzi | last post by:
I'm trying to implement a very simple http server with cgi functionality. The code is simple: import CGIHTTPServer, BaseHTTPServer httpd = BaseHTTPServer.HTTPServer(('',8000),...
7
by: mx2k | last post by:
Hello @ all, we have written a small program (code below) for our own in-developement rpg system, which is getting values for 4 RPG-Characters and doing some calculations with it. now we're...
38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
5
gekko3558
by: gekko3558 | last post by:
I am writing a simple binary search tree (nodes are int nodes) with a BSTNode class and a BST class. I have followed the instructions from my C++ book, and now I am trying to get a remove method...
6
by: SuperFool | last post by:
This has got to be one of those questions only a serious newbie would come up with.... Basicly: I select all the city names in the table and turn them into a pull down menu (code below) print...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.