how to get a index of items in list view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivekajain123456789
    New Member
    • Feb 2007
    • 1

    how to get a index of items in list view

    any one can write code for the above tittle
  • dshimer
    Recognized Expert New Member
    • Dec 2006
    • 136

    #2
    Can you give an example of what you're looking for? As I understand it the "index" relates to the position of elements in a "list", so "index of items in list view" is a little confusing (to me). Do you by chance want to print out each item in some sequence data?

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      Originally posted by vivekajain12345 6789
      any one can write code for the above tittle
      Are you asking a question? Could you be more specific - maybe show an example of what you need? Following is a function I use that returns an index list:
      Code:
      s = [1,2,3,4,1,2,3,4,1,2,4,3,4,5,6,6,7,8,9,1,2,3,4,5,6,7,3,2,1]
      
      def get_index(s, item):
          i = 0
          i_list = []
          while True:
              try:
                  i = s.index(item, i)
                  i_list.append(i)
                  i += 1
              except:
                  break
          return i_list
      
              
      print get_index(s, 1)
      print get_index(s, 4)
      print get_index(s, 7)
      print get_index(s, 0)
      
      >>> [0, 4, 8, 19, 28]
      [3, 7, 10, 12, 22]
      [16, 25]
      []
      >>>

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        A list view sounds like a GUI element. Is this correct? (oh, boy, I love guessing games) If so, which Toolkit are you using?

        Comment

        Working...