Re: Problem with a for loop and a list

2008-07-02 Thread Bruno Desthuilliers
Alexnb a écrit : I am not sure what is going on here. Here is the code that is being run: def getWords(self): self.n=0 for entry in self.listBuffer: self.wordList[self.n] = entry.get() self.n=self.n+1 print self.wordList def get_words(self):

Re: Problem with a for loop and a list

2008-07-02 Thread John McMonagle
Alexnb wrote: > well okay, so what can I do? > > > Firstly, stop top posting. Replies to a thread "flow" better if bottom posted. Secondly, it sounds like you want to build a list of the results from your entry.get() calls. Try this: self.wordList = [] def getWords(self): for entry in se

Re: Problem with a for loop and a list

2008-07-02 Thread Peter Otten
Alexnb wrote: > > I am not sure what is going on here. Here is the code that is being run: > > def getWords(self): > self.n=0 The value of self.n only makes sense within the method, so you better use the local variable n instead of the instance attribute self.n > for entry in s

Re: Problem with a for loop and a list

2008-07-02 Thread Alexnb
Actually I tried that and had no sucsess, but I just figured it out. I set every value in wordList to 'None' and so even if all the entry fields aren't taken up, they go to '', so I can tell what is and what isn't taken up, and get the string of the ones that are taken up. Terry Reedy wrote: >

Re: Problem with a for loop and a list

2008-07-02 Thread Terry Reedy
Alexnb wrote: I am not sure what is going on here. Here is the code that is being run: def getWords(self): self.n=0 for entry in self.listBuffer: self.wordList[self.n] = entry.get() And what does self.wordList begin as? If {}, then the assignemt is invalid. Per

Re: Problem with a for loop and a list

2008-07-02 Thread Alexnb
well okay, so what can I do? A.T.Hofkamp-3 wrote: > > On 2008-07-02, Alexnb <[EMAIL PROTECTED]> wrote: >> I have no idea what "list assignment index out of range means?!?! > > You are assigning a value to a non-existing list element, as in > x = [1] x[2] = 4 > Traceback (most recen

Re: Problem with a for loop and a list

2008-07-02 Thread A.T.Hofkamp
On 2008-07-02, Alexnb <[EMAIL PROTECTED]> wrote: > I have no idea what "list assignment index out of range means?!?! You are assigning a value to a non-existing list element, as in >>> x = [1] >>> x[2] = 4 Traceback (most recent call last): File "", line 1, in ? IndexError: list assignment in