how could i empty the array which is already filled with data?
i tried everything, splice, clear, assigning some empty data and still nothing.
the array is defined globally, for example myarray = []
and then filled with data with myarray.append('something')
ok, now i know:
Quote:for i in range(0, len(myarray)):
myarray.pop()
i 'borrowed' it from gametrailers script
and sorry for posting in wrong forum (now corrected).
(d.i.z @ dec. 16 2004,23:44 Wrote:how could i empty the array which is already filled with data?
i tried everything, splice, clear, assigning some empty data and still nothing.
the array is defined globally, for example myarray = []
and then filled with data with myarray.append('something')
i think
myarray[:] = []
which is equivalent to
myarray[0:len(myarray) - 1] = []
explicitly deletes every element.
(d.i.z @ dec. 17 2004,00:55 Wrote:ok, now i know:
Quote:for i in range(0, len(myarray)):
myarray.pop()
i 'borrowed' it from gametrailers script
and sorry for posting in wrong forum (now corrected).
haha im the gametrailers author and was abt to post the same thing. i cant find a better method to delete though, will try asteron method nxt time
what about
myarray=[] ?
or
del myarray
i think that those two dont free up what the list refers to
from
http://rgruet.free.fr/pqr2.3.html#list
s.pop() is the same as x = s[-1]; del s[-1]; return x
where s[-1] = s[len(s)-1]
also s[:] = [] is the same as s[0:len(s)-1] = []
which is the same as del s[0:len(s)-1]
i really would wish there was a nice clear() though.