Re: modifying a list while iterating through

2007-02-26 Thread Steven D'Aprano
On Mon, 26 Feb 2007 13:45:36 -0800, dustin.getz wrote: > My original question still stands, though, in situations where a > simple string replacement might not be sufficient. Is there a way to > insert into a list whilst iterating through it? Inserting/deleting from a list while you're walking t

Re: modifying a list while iterating through

2007-02-26 Thread dustin . getz
On Feb 25, 9:15 pm, [EMAIL PROTECTED] wrote: > On Feb 25, 5:12 pm, [EMAIL PROTECTED] wrote: > > > consider the following working loop where Packet is a subclass of > > list, with Packet.insert(index, iterable) inserting each item in > > iterable into Packet at consecutive indexes starting at index.

Re: modifying a list while iterating through

2007-02-25 Thread attn . steven . kuo
On Feb 25, 5:12 pm, [EMAIL PROTECTED] wrote: > consider the following working loop where Packet is a subclass of > list, with Packet.insert(index, iterable) inserting each item in > iterable into Packet at consecutive indexes starting at index. > > i=0 > while(i if packet[i:i+5]==Pa

Re: modifying a list while iterating through

2007-02-25 Thread George Sakkis
On Feb 25, 8:12 pm, [EMAIL PROTECTED] wrote: > consider the following working loop where Packet is a subclass of > list, with Packet.insert(index, iterable) inserting each item in > iterable into Packet at consecutive indexes starting at index. > > i=0 > while(i if packet[i:i+5]==Pa

modifying a list while iterating through

2007-02-25 Thread dustin . getz
consider the following working loop where Packet is a subclass of list, with Packet.insert(index, iterable) inserting each item in iterable into Packet at consecutive indexes starting at index. i=0 while(ihttp://mail.python.org/mailman/listinfo/python-list