Re: what's the python for this C statement?

2008-10-21 Thread Hrvoje Niksic
Lie Ryan [EMAIL PROTECTED] writes: On Mon, 20 Oct 2008 12:34:11 +0200, Hrvoje Niksic wrote: Michele [EMAIL PROTECTED] writes: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Please use

what's the python for this C statement?

2008-10-20 Thread Michele
Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) which is equivalent to: for (i = 0; i 10; i++) However, how this C statement will be translated in Python? for (j = i = 0; i (1 H); i++)

Re: what's the python for this C statement?

2008-10-20 Thread Chris Rebert
On Mon, Oct 20, 2008 at 2:56 AM, Michele [EMAIL PROTECTED] wrote: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Actually, you want: for i in range(10): Since starting at 0 and using a step

Re: what's the python for this C statement?

2008-10-20 Thread Hrvoje Niksic
Michele [EMAIL PROTECTED] writes: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Please use xrange for this purpose, especially with larger iterations. range actually allocates a sequence.

Re: what's the python for this C statement?

2008-10-20 Thread Lie Ryan
On Mon, 20 Oct 2008 12:34:11 +0200, Hrvoje Niksic wrote: Michele [EMAIL PROTECTED] writes: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Please use xrange for this purpose, especially

Re: what's the python for this C statement?

2008-10-20 Thread Terry Reedy
Lie Ryan wrote: (which might be the more typical case). And I think range will be an iterator in the future, imitating the behavior of xrange. So it doesn't really matter anyway. In 3.0, range is a class and range(arg) is a re-iterable instance of that class. a = range(10,2,-3) a

Re: what's the python for this C statement?

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 17:01:13 +, Lie Ryan wrote: On Mon, 20 Oct 2008 12:34:11 +0200, Hrvoje Niksic wrote: Michele [EMAIL PROTECTED] writes: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in