simple files
Andreas Jung
lists at andreas-jung.com
Sat May 31 02:24:22 EDT 2003
--On Freitag, 30. Mai 2003 23:18 Uhr -0700 Darren Teo
<darrenteo82 at yahoo.com> wrote:
>
> Hey how come when i do this it just outputs the last line and not the
> rest of the lines ??? I wish to output each line from file into a
> seperate list ..... eg. first line ['1', 'yea', '2']
> sec line ['3', 'hi', '4']
>
> def readtable(filename):
>
> intabfile = open(filename, "r")
> for tablines in intabfile:
> tab = string.split(tablines, ":" ,10)
> intabfile.close()
> return tab
>
because tab is assigned the content of the last line in the last iteration
of the loop.
so what else do you expect??
-aj
More information about the Python-list
mailing list