In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote: > > i need to be able to get the index for an item in a list. > > > any ideas? > > Fire up the interactive interpreter and learn to use it to help > yourself. In this case, the most useful thing might be to know about > the dir() builtin method, which you can use on a list like so: > > dir([]) > > Note in the output the presence of the "index" method... I'll leave it > up to you to read the docs to learn more about how to use it, or you can > just experiment at the prompt to see how it works. > > -Peter I certainly agree that dir() is a very handy tool to know about, and that poking around with it in the interactive interpreter is a great way to learn what's possible. That being said, index() isn't isn't going to work if there are duplicate lines in the file; it'll return the index of the first one. -- http://mail.python.org/mailman/listinfo/python-list