Op 2005-04-21, Raymond Hettinger schreef <[EMAIL PROTECTED]>: >> > [Antoon Pardon] >> >> I don't see why the start index can't be accessible through >> >> a method or function just like the length of a list is now. >> >> >> >> My favourite would be a range method so we would have >> >> the following idiom: >> >> >> >> for i in lst.range(): >> >> do something with lst[i] >> > >> > After going to all that trouble, you might as well also get the value at > that >> > position: >> > >> > for i, x in enumerate(lst): >> > do something with lst[i] also known as x >> >> No you wouldn't, enumerate always starts with 0. > > You don't get it. Your proposed list-like class indicates its start index. > enumerate() can be made to detect that start value so that the above code > always > works for both 0-based and 1-based arrays.
Oh you mean if it would be made a buildin class. Personnally I would still prefer my range solution. I often find enumerate gives me too much. Often enough I want to assign new values to the elements in the list. I have no need for the old value, that is also provided by enumerate. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list