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
If the former, you would overwrite previous assignment (if > it worked) for every item except the last. > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- View this message in context: http://www.nabble.com/Problem-with-a-for-loop-and-a-list-tp18232298p18232

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
> x = [1] >>>> x[2] = 4 > Traceback (most recent call last): > File "", line 1, in ? > IndexError: list assignment index out of range > > > Albert > -- > http://mail.python.org/mailman/listinfo/python-list > > -- View this message in conte

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

Problem with a for loop and a list

2008-07-02 Thread Alexnb
ange I have no idea what "list assignment index out of range means?!?! -- View this message in context: http://www.nabble.com/Problem-with-a-for-loop-and-a-list-tp18232298p18232298.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list