473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to get a index of items in list view

any one can write code for the above tittle
Feb 12 '07 #1
3 1860
dshimer
136 Expert 100+
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?
Feb 12 '07 #2
bvdet
2,851 Expert Mod 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. 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]
  2.  
  3. def get_index(s, item):
  4.     i = 0
  5.     i_list = []
  6.     while True:
  7.         try:
  8.             i = s.index(item, i)
  9.             i_list.append(i)
  10.             i += 1
  11.         except:
  12.             break
  13.     return i_list
  14.  
  15.  
  16. print get_index(s, 1)
  17. print get_index(s, 4)
  18. print get_index(s, 7)
  19. print get_index(s, 0)
  20.  
  21. >>> [0, 4, 8, 19, 28]
  22. [3, 7, 10, 12, 22]
  23. [16, 25]
  24. []
  25. >>>
Feb 12 '07 #3
bartonc
6,596 Expert 4TB
A list view sounds like a GUI element. Is this correct? (oh, boy, I love guessing games) If so, which Toolkit are you using?
Feb 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
5
by: Jax | last post by:
Dear all, I have a list view, i dont like this list view very much anymore as it hasn't been the easiest object to use thus far. Now i like it even less. I have a problem with it, I wish to...
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
14
by: Rich | last post by:
Yes, I need to store some values in an array type collection object that can hold 3 or more parameters per index. I have looked at the collection object, hashtable object and would prefer not to...
3
by: Brian Henry | last post by:
So what is the easiest way to do this? I have one list view with a list of items (in detail view and with about 20 sub items) and a second list view that will take the items they drag from the...
10
by: Adam Honek | last post by:
This is probably a silly question but oh well, I can't find the answer looking via code. Having an imagelist already, how does one set an icon for a list view's sub items? I'm using the code...
1
by: lb | last post by:
Hello, I am trying to use a radiobuttonlist with the new multiview control. Am having trouble understanding how to build the radiobuttonlsit just one time, and not many times. In my first...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
I've a multiview with 3 views. on view 2 the user is presented with a check box list (items from database) at view 3 the user can review their selections and, either post to the database or go back...
3
by: Riccardo Murri | last post by:
Hello, I have some code that stops when trying to find a graph in a list of similar graphs:: (Pydb) list 110 try: 111 canonical = self.base 112 except ValueError: 113 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.