Hi tutor, thanks for the help ,u dont understand cause i have given the psudo code,i have not given the full code only apart of it. I only want an emptty array and put the value [i] in it. This [i] value is the one that i want to show.Im making this activity in glade ,the set function in image widget do not replace the previous value but in the next loop it shows the previous images as well as the new one .It dont replace,but set again and again. So i want to declare an empty array then i want to give it a value[i] ,this [i] is the number of images that i want to show, but on next loop i want the array to be empty,and then sets new value of [i].
self.fixed = self.wTree.get_widget("fixed1") self.numOne = random.randint(1,10) for i in [ ]: for i in range(self.numOne): a = [i] self.image = gtk.Image() self.image.set_from_file("./Pink-Flower-32x32.png") self.fixed.put(self.image, i*25, 0) self.image.show() thanks On Sat, Jan 3, 2009 at 6:01 PM, Kent Johnson <ken...@tds.net> wrote: > On Sat, Jan 3, 2009 at 3:16 AM, i i <iaid...@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 >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor