William Meyer wrote: > I need to get the index of an object in a list. I know that no two objects > in the list are the same, but objects might evaluate as equal. for example > > list = [obj1, obj2, obj3, obj4, obj5] > for object in list: > objectIndex = list.index(object) > print objectIndex
for objectIndex, object in enumerate(list): print objectIndex, object (note that both object and list are commonly used builtins, so you should probably use other names in your code to avoid weird TypeErrors later on). </F> -- http://mail.python.org/mailman/listinfo/python-list