[Tutor] Blank line added after reading a line from a file

Kelly, Phelim KellyPhe@logica.com
Wed, 5 Dec 2001 12:29:55 -0000


(I'll try this again!)

Hello, 
I have a small probelm, hope you can help. I'm reading text from an external
file into a python program as follows: 

---------------------
filename = raw_input("Enter the filename to read from: "); 
p=0
in_file = open(filename,"r")
while p < 4:
   text = in_file.readline()
   list[p]=text #list is an array which stores the content of each line read

                #in.
   p = p + 1
in_file.close()
---------------------------

The problem I have is that the text that is stored in variable 'text' isn't
simply the contents of one line of the file, another blank line is appended
onto the end, which causes problems for the rest of the program, so instead
of this, 
--------------------- 
line read in from file 
-------------------- 

I get this, 

------------------- 
line read in from file 

------------------- 
Can anyone tell me the command used to get rid of the extra blank line added
on? 
Thanks in advance, 
Phelim.

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.