Neal Becker wrote:
> I see list has index member, but is there an index function that applies to
> any sequence type?

Like this?

  def find_index(seq, value):
      try:
          find_index = seq.index
      except AttributeError:
          def find_index(value):
              for i,v in enumerate(seq):
                   if v == value: return i
              raise ValueError("index(seq, x): x not in sequence")
      return find_index(value)


> If not, shouldn't there be?

I don't see the need.

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to