[Tutor] create an empty array of images

Kent Johnson kent37 at tds.net
Sat Jan 3 14:01:22 CET 2009


On Sat, Jan 3, 2009 at 3:16 AM, i i <iaidas4 at gmail.com> wrote:
> yes i want to clear the images before the next iteration,here is the pseudo
> code what i want to do
>
> a = [ ]
> for i in range(self.numOne)
> a.append([i])
>  to create an empty array, and append the index i to the array and pass this
> index to gtk image,how i can do this in for-in statement

I don't understand your question but I will make a few guesses.

The code you show above creates a list whose elements are also lists:
In [12]: a = []

In [13]: for i in range(5):
   ....:     a.append([i])

In [14]: a
Out[14]: [[0], [1], [2], [3], [4]]

If you want a list containing all the values of i, just use the
range() function directly:
In [15]: range(5)
Out[15]: [0, 1, 2, 3, 4]

If you want a list containing a single value of i, create a new list
each time through the loop:
In [16]: for i in range(5):
   ....:     a = [i]
   ....:     print a

[0]
[1]
[2]
[3]
[4]

HTH,
Kent


More information about the Tutor mailing list