This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pop functioning
Type: behavior Stage: resolved
Components: Regular Expressions Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Padmanabhan.Tr, ezio.melotti, mrabarnett, steven.daprano
Priority: normal Keywords:

Created on 2015-06-06 11:04 by Padmanabhan.Tr, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug_a Padmanabhan.Tr, 2015-06-06 11:04 as in attachment
Messages (3)
msg244897 - (view) Author: Padmanabhan Tr (Padmanabhan.Tr) * Date: 2015-06-06 11:04
I have attached the python sequence & my comments. I use Python version 3.4.2
I guess a bug need be corrected
msg244898 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2015-06-06 11:42
The behaviour is correct, this is not a bug. Each time you pop from aa, the following items move down one space. Then, the next time you pop, the items have moved:

['a0', 'b1', 'c2', 'd3', 'e4', 'f5', 'g6', 'h7', 'i8', 'j9', 'k10', 'l11']
d3 is the third item and gets popped;

['a0', 'b1', 'c2', 'e4', 'f5', 'g6', 'h7', 'i8', 'j9', 'k10', 'l11']
g6 is the fifth item and gets popped;

['a0', 'b1', 'c2', 'e4', 'f5', 'h7', 'i8', 'j9', 'k10', 'l11']
j9 is the seventh item and gets popped.


To get the result you want, you can use slicing:

aa[3:9:2]
=> returns ['d3', 'f5', 'h7']

then

del aa[3:9:2]
=> leaves ['a0', 'b1', 'c2', 'e4', 'g6', 'i8', 'j9', 'k10', 'l11']
msg244941 - (view) Author: Padmanabhan Tr (Padmanabhan.Tr) * Date: 2015-06-07 04:16
Dear StevenThank you.  
I am clear now.Padmanabhan

     On Saturday, June 6, 2015 5:12 PM, Steven D'Aprano <report@bugs.python.org> wrote:

Steven D'Aprano added the comment:

The behaviour is correct, this is not a bug. Each time you pop from aa, the following items move down one space. Then, the next time you pop, the items have moved:

['a0', 'b1', 'c2', 'd3', 'e4', 'f5', 'g6', 'h7', 'i8', 'j9', 'k10', 'l11']
d3 is the third item and gets popped;

['a0', 'b1', 'c2', 'e4', 'f5', 'g6', 'h7', 'i8', 'j9', 'k10', 'l11']
g6 is the fifth item and gets popped;

['a0', 'b1', 'c2', 'e4', 'f5', 'h7', 'i8', 'j9', 'k10', 'l11']
j9 is the seventh item and gets popped.

To get the result you want, you can use slicing:

aa[3:9:2]
=> returns ['d3', 'f5', 'h7']

then

del aa[3:9:2]
=> leaves ['a0', 'b1', 'c2', 'e4', 'g6', 'i8', 'j9', 'k10', 'l11']

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue24392>
_______________________________________
History
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68580
2015-06-07 04:16:11Padmanabhan.Trsetmessages: + msg244941
2015-06-06 11:42:13steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg244898

resolution: not a bug
stage: resolved
2015-06-06 11:04:05Padmanabhan.Trcreate