[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread miss-islington
miss-islington added the comment: New changeset 75dd70e1ce0b5ce50c572802c17b7fa427d9ce23 by Miss Skeleton (bot) in branch '3.9': bpo-41774: Tweak new programming FAQ entry (GH-22562) https://github.com/python/cpython/commit/75dd70e1ce0b5ce50c572802c17b7fa427d9ce23 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread miss-islington
miss-islington added the comment: New changeset 7e941fa8e0454c7814ce3ec646136758c0db5a25 by Miss Skeleton (bot) in branch '3.8': bpo-41774: Tweak new programming FAQ entry (GH-22562) https://github.com/python/cpython/commit/7e941fa8e0454c7814ce3ec646136758c0db5a25 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread miss-islington
Change by miss-islington : -- pull_requests: +21559 pull_request: https://github.com/python/cpython/pull/22564 ___ Python tracker ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread miss-islington
Change by miss-islington : -- pull_requests: +21558 pull_request: https://github.com/python/cpython/pull/22563 ___ Python tracker ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 060937da988347a887a5f165b023d972fcb97802 by Terry Jan Reedy in branch 'master': bpo-41774: Tweak new programming FAQ entry (GH-22562) https://github.com/python/cpython/commit/060937da988347a887a5f165b023d972fcb97802 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-05 Thread Terry J. Reedy
Change by Terry J. Reedy : -- pull_requests: +21557 pull_request: https://github.com/python/cpython/pull/22562 ___ Python tracker ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-10-04 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> terry.reedy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: > If space is not an issue, the list comprehension may be fastest. I think there is still a misunderstanding here. The generator variant does not save space. It uses slightly *more* space than the list variant. The list_ass_slice()ยน function runs

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-28 Thread miss-islington
miss-islington added the comment: New changeset 868c8e41eb1d7dc032679ae06e62c0d60edd7725 by Miss Islington (bot) in branch '3.9': bpo-41774: Add programming FAQ entry (GH-22402) https://github.com/python/cpython/commit/868c8e41eb1d7dc032679ae06e62c0d60edd7725 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-28 Thread miss-islington
miss-islington added the comment: New changeset d50a0700265536a20bcce3fb108c954746d97625 by Miss Islington (bot) in branch '3.8': bpo-41774: Add programming FAQ entry (GH-22402) https://github.com/python/cpython/commit/d50a0700265536a20bcce3fb108c954746d97625 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-28 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 6.0 -> 7.0 pull_requests: +21477 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/22447 ___ Python tracker

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-28 Thread miss-islington
Change by miss-islington : -- pull_requests: +21478 pull_request: https://github.com/python/cpython/pull/22448 ___ Python tracker ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-28 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 5b0181d1f6474c2cb9b80bdaf3bc56a78bf5fbe7 by Terry Jan Reedy in branch 'master': bpo-41774: Add programming FAQ entry (GH-22402) https://github.com/python/cpython/commit/5b0181d1f6474c2cb9b80bdaf3bc56a78bf5fbe7 --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: Sorry for the wording of the last message. Go ahead with whatever you would like do :-) Was only trying to point-out that the generator semantics don't interact nicely with slice assignments: $ python3.9 -m timeit -s 'a=list(range(1000))' 'b=a[:]'

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-25 Thread Terry J. Reedy
Terry J. Reedy added the comment: Raymond, please take what I have written and rewrite it to your satisfaction. I have lots else to do, including investigating the IDLE bug you just reported. -- assignee: terry.reedy -> ___ Python tracker

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I like the simple ad easy 'slice replacement = iterator' form > because it illustrates to me that we have done something > right with Python's design. I understand that you like it and that it reflects the way you think the world should work, , but

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: Timings depend on multiple factors, including implementation (cpython versus pypy versus cython, etc) and complexity of the keep/discard decision. I said in the proposed text that a listcomp may be faster. I think that sufficient; anyone who cares can test

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: Try running some timings. I suspect the genexp/iterator versions run more slowly. The speed of the slice replacement relies on knowing the size of the input. -- ___ Python tracker

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: You are right; the replacement index I called 'j' is better buried as a C index or pointer within a slice replacement. In fact, a generator expression, if one has a keep expression, or a filter call, if one has filter function, work, without the

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The usually recommended alternative is to make a new list of > things not deleted. But one can do this in-place by writing > the new list on top of the old by using a explicit second > index to move items just once. I don't think we should send users

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Terry J. Reedy
Change by Terry J. Reedy : -- keywords: +patch pull_requests: +21442 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/22402 ___ Python tracker

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: I modeled the new entry on the previous one. The code and its test. def fr(n, remove): mylist = list(range(n)) for i in range(len(mylist)-1, -1, -1): if remove(mylist[i]): del mylist[i] return mylist def ff(n, keep):

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Terry J. Reedy
Terry J. Reedy added the comment: Sreedevi: the Windows tag is meant for issues that involve Windows behavior that is different from other OSes; the IDLE tag is meant for issues that involve the behavior of IDLE, as distinct from other ways of running Python code. They should not be used

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Paul Moore
Paul Moore added the comment: Yeah, apologies - I saw the email notification, but Eric removed me from the nosy list (quite reasonably) and I didn't notice there had been extra discussion :-( If someone wants to re-open the issue, feel free. --

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: I think Eric left the issue open because he was hoping to update the FAQs and/or docs with information about this issue. I will leave it to someone else to decide whether or not to reopen it. -- ___ Python

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Paul Moore
Paul Moore added the comment: There is a bug in your program. You should not mutate the list while looping over it. -- nosy: +paul.moore ___ Python tracker ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Paul Moore
Change by Paul Moore : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: You say: "output should be empty list" but that's not actually correct. You intend the output to be the empty list, but if you think carefully about what happens during iteration, you should see that the behaviour is correct. To make it easier to see

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Eric V. Smith
Eric V. Smith added the comment: Removing Windows and IDLE devs from nosy list, since this isn't related to either of those areas. -- nosy: -paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware ___ Python tracker

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Eric V. Smith
Eric V. Smith added the comment: You should not mutate a list while iterating over it. See, for example https://stackoverflow.com/questions/6260089/strange-result-when-removing-item-from-a-list I couldn't find a place where this is mentioned in the python list docs. If it's not there, we

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Eric V. Smith
Change by Eric V. Smith : -- components: +Documentation -IDLE, Windows ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue41774] While removing element from list using for and remove(), which has same items output is not right

2020-09-12 Thread Sreedevi
New submission from Sreedevi : Define a list which has all same elements. While removing the same element from list using for loop and by using remove() method, output should be empty list, but the output we get is one element is unremoved -- assignee: terry.reedy components: IDLE,