[Python-bugs-list] [ python-Feature Requests-754014 ] list.index() should accept optional start, end arguments

SourceForge.net noreply@sourceforge.net
Mon, 16 Jun 2003 22:07:08 -0700


Feature Requests item #754014, was opened at 2003-06-13 10:13
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=754014&group_id=5470

Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Peter Hansen (phansen)
Assigned to: Raymond Hettinger (rhettinger)
Summary: list.index() should accept optional start, end arguments

Initial Comment:
As with the .index() method on strings, which allows 
scanning only a subset of the string by specifying 
optional start and end arguments, the list type's index() 
method should do the same.

The use case comes from the thread started here: 
http://mail.python.org/pipermail/python-list/2003-
June/168225.html .  

A later posting shows a list-comprehension-based 
solution which is fairly clean, but relies on generating a 
temporary utility list using range() (or xrange()).  
Another easy alternative would be to manually create 
subsets of the list using slicing, but that would involve a 
lot of overhead compared to including it in the index() 
method itself.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-17 00:07

Message:
Logged In: YES 
user_id=80475

Committed to Objects/listobject.c 2.154 and Lib/UserList.py 
1.19.   Updated both test suites to match.  Closing RFE.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-16 09:06

Message:
Logged In: YES 
user_id=80475

Okay, I'll put this one in.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=754014&group_id=5470