Re: [Tutor] counting a list of elements

2011-04-01 Thread Karim
On 04/02/2011 07:00 AM, Knacktus wrote: Am 01.04.2011 21:31, schrieb Karim: On 04/01/2011 08:41 PM, Knacktus wrote: Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the

Re: [Tutor] counting a list of elements

2011-04-01 Thread Knacktus
Am 01.04.2011 21:31, schrieb Karim: On 04/01/2011 08:41 PM, Knacktus wrote: Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the range 1e3 and 1e6. 1) I could create a g

Re: [Tutor] counting a list of elements

2011-04-01 Thread Karim
On 04/01/2011 08:41 PM, Knacktus wrote: Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the range 1e3 and 1e6. 1) I could create a generator and set a counter (i +=1) in

Re: [Tutor] counting a list of elements

2011-04-01 Thread Knacktus
Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the range 1e3 and 1e6. 1) I could create a generator and set a counter (i +=1) in the loop. 2) or simply len(mylist). I

Re: [Tutor] counting a list of elements

2011-04-01 Thread James Reynolds
The nice thing about Python is you don't have to build things from scratch, and I imagine most people would discourage on account of it being a waste of time, other then education value. But the "best practice" in my humble opinion would be to use the built in len function. If what you are after i

Re: [Tutor] counting a list of elements

2011-04-01 Thread Knacktus
Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). It's not clear to me what your starting point is. If you don't have a list and don't need a list, but have a large number of objects you create in y

Re: [Tutor] counting a list of elements

2011-04-01 Thread Emile van Sebille
On 4/1/2011 10:16 AM Karim said... I would like to get advice on the best practice to count elements Well, I suspect you're more interested in knowing the total count of how many as opposed to counting how many. To get the total count of how many use len(mylist). Emile __

[Tutor] counting a list of elements

2011-04-01 Thread Karim
Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the range 1e3 and 1e6. 1) I could create a generator and set a counter (i +=1) in the loop. 2) or simply len(mylist). I don't need the content of the list,