Message164219
| Author |
Eklutna |
| Recipients |
Eklutna |
| Date |
2012年06月28日.03:44:51 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1340855093.79.0.494705749272.issue15214@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The simple repro below, shows that if a list of strings has two consecutive items that begin with the same letter, an iteration over the list to find and remove all strings that start with that letter fails. The second string that starts with the same letter to remove remains in the list.
In the example below, both "bananna" and "blueberry" should be removed from the list, but only "bananna" is removed.
I verified this on both 2.7 and 3.2.
-----------------------------------------------------
--- Output ---
--------------
Before: ['apple', 'bananna', 'blueberry', 'coconut']
After: ['apple', 'blueberry', 'coconut']
-----------------------------------------------------
--- Repro ---
-------------
itemList = ["apple", "bananna", "blueberry", "coconut"]
print("Before: {0}".format(itemList))
for item in itemList:
if(item.startswith("b")):
itemList.remove(item)
print("After: {0}".format(itemList)) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年06月28日 03:44:54 | Eklutna | set | recipients:
+ Eklutna |
| 2012年06月28日 03:44:53 | Eklutna | set | messageid: <1340855093.79.0.494705749272.issue15214@psf.upfronthosting.co.za> |
| 2012年06月28日 03:44:52 | Eklutna | link | issue15214 messages |
| 2012年06月28日 03:44:52 | Eklutna | create |
|