[Tutor] function loading a file's lines to a list
Adriano Varoli Piazza
moranar at moranar.com.ar
Fri Apr 1 12:58:51 CEST 2005
Il giorno ven, 01-04-2005 alle 12:46 +0200, Ewald Ertl ha scritto:
> Hi!
>
> on Fri, 01 Apr 2005 12:01:02 +0200 Adriano Varoli Piazza <moranar at moranar.com.ar> wrote :
> ---------------------------------------------------------------------------------------------
>
> Adriano Varoli Piazza >
> Adriano Varoli Piazza > def loadfromfile(fname):
> Adriano Varoli Piazza > try:
> Adriano Varoli Piazza > finput = file(fname, 'r')
> Adriano Varoli Piazza > global lines
>
> global say, that lines is "global" defined. Otherwise as in your first
> version the lines-List is defined local in the loadfromfile()-function.
> (You can return the local list and assign it, where you call the loadfromfile()-
> function. )
I understand now. I got confused with "lists elements are changed in
place"... Thanks
--
Adriano Varoli Piazza
The Inside Out: http://moranar.com.ar
MSN: adrianomd at hotmail.com
ICQ: 4410132
More information about the Tutor
mailing list