Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-04 Thread Martin v. Löwis
Brian Harring schrieb: >> I think this is incorrect. The implementation could well support it, >> putting a dummy object into the deleted key (which deletion needs >> to do, anyway). > > The implementation already uses a sentinel (NULL)- That' not the full truth. The implementation has a separate

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-04 Thread Brian Harring
On Mon, Dec 04, 2006 at 07:15:35PM +0100, "Martin v. L??wis" wrote: > Brian Harring schrieb: > > For dict; it actually *cannot* work. You can't remove keys from a > > dict as you're iterating over it (can change the val of a key, but not > > remove the key). > > I think this is incorrect. The i

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-04 Thread Martin v. Löwis
Ben Wing schrieb: > i do see your point. i was trying to remember what i ended up doing > when i ran into this issue before, and in fact i ended up just making a > new list and appending all the elements i didn't want to delete. i see > you'd get N^2 behavior if you deleted lots of elements fr

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-04 Thread Martin v. Löwis
Brian Harring schrieb: > For dict; it actually *cannot* work. You can't remove keys from a > dict as you're iterating over it (can change the val of a key, but not > remove the key). I think this is incorrect. The implementation could well support it, putting a dummy object into the deleted key

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Ben Wing
Brian Harring wrote: > On Sun, Dec 03, 2006 at 08:35:58PM -0600, Ben Wing wrote: > >> but i still don't see why supporting iter.delete() is so wrong. clearly >> it doesn't need to work on files or other such things where it doesn't >> make sense. >> >> before you diss this completely, note

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Brian Harring
On Sun, Dec 03, 2006 at 08:35:58PM -0600, Ben Wing wrote: > but i still don't see why supporting iter.delete() is so wrong. clearly > it doesn't need to work on files or other such things where it doesn't > make sense. > > before you diss this completely, note that java supports exactly the > s

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Ben Wing
Brian Harring wrote: > On Sun, Dec 03, 2006 at 06:24:17AM -0600, Ben Wing wrote: > >> many times writing somewhat complex loops over lists i've found the need >> to sometimes delete an item from the list. currently there's no easy >> way to do so; basically, you have to write something like >

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Adam Olsen
On 12/3/06, Ben Wing <[EMAIL PROTECTED]> wrote: > many times writing somewhat complex loops over lists i've found the need > to sometimes delete an item from the list. currently there's no easy > way to do so; basically, you have to write something like As I don't believe there's any need for a l

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Martin v. Löwis
Ben Wing schrieb: > i'd much rather see something like: > > for x:iter in list: > ...do something... > if x should be deleted: > iter.delete() You can easily implement that feature yourself if you need it, at least for lists (or sequences that support integer indexing): class deletable_i

Re: [Python-Dev] a feature i'd like to see in python #1: better iteration control

2006-12-03 Thread Brian Harring
On Sun, Dec 03, 2006 at 06:24:17AM -0600, Ben Wing wrote: > many times writing somewhat complex loops over lists i've found the need > to sometimes delete an item from the list. currently there's no easy > way to do so; basically, you have to write something like > > i = 0 > while i < len(list):