[google-appengine] Re: is it a bug of python 2.5?----remove elements from list in for cycle
a = set(a) a.discard(b) a = list(a) On 6月1日, 下午8时48分, DiveIntoGAE taogf1...@gmail.com wrote: a=[b,c,t,y,b,b,b,b] a ['b', 'c', 't', 'y', 'b', 'b', 'b', 'b'] for i in a: a.remove(b) # why can't i remove all the b from list a? a ['c', 't', 'y', 'b'] # this is the result after the for cycle a.remove(b) a ['c', 't', 'y']# i need to remove the last b a second time --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: is it a bug of python 2.5?----remove elements from list in for cycle
a=[b,c,t,y,b,b,b,b] a=[i for i in a if i != 'b'] a ['c', 't', 'y'] a=[b,c,t,y,b,b,b,b] a = filter(lambda x: x != 'b', a) a ['c', 't', 'y'] 2009/6/1 秦锋 feng.w@gmail.com a = set(a) a.discard(b) a = list(a) On 6月1日, 下午8时48分, DiveIntoGAE taogf1...@gmail.com wrote: a=[b,c,t,y,b,b,b,b] a ['b', 'c', 't', 'y', 'b', 'b', 'b', 'b'] for i in a: a.remove(b) # why can't i remove all the b from list a? a ['c', 't', 'y', 'b'] # this is the result after the for cycle a.remove(b) a ['c', 't', 'y']# i need to remove the last b a second time --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: is it a bug of python 2.5?----remove elements from list in for cycle
2009/6/1 秦锋 feng.w@gmail.com a = set(a) a.discard(b) a = list(a) ==I tried this, It works! -- Chunlei Zhang Ph.D. candidate Major: Curriculum Teaching Scholar Interests: science education; teacher training ; teacher knowledge; pck; concept map Biology Teaching Club:http://groups.google.com/group/bioteahouse --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---