Georg Brandl <[EMAIL PROTECTED]> wrote:
> Steven D'Aprano wrote:
> > On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote:
> >
> >> [EMAIL PROTECTED] wrote:
> >>> hi John,
> >>> Python doesn't provide for loop like C / C++ but using Range() or
> >>> Xrange() you can achive all the function
Steven D'Aprano wrote:
> On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote:
>
>> [EMAIL PROTECTED] wrote:
>>> hi John,
>>> Python doesn't provide for loop like C / C++ but using Range() or
>>> Xrange() you can achive all the functionalities of the C for loop.
>>
>> Not quite.
>
> Care
Steven D'Aprano wrote:
> On Wed, 05 Apr 2006 16:21:02 +0200, Georg Brandl wrote:
>
>> Because of backwards compatibility. range() returns a list, xrange() an
>> iterator: list(xrange(...)) will give the same results as range(...).
>
> Georg is pretty much correct in his explanation, but just to d
On Wed, 05 Apr 2006 16:21:02 +0200, Georg Brandl wrote:
> Because of backwards compatibility. range() returns a list, xrange() an
> iterator: list(xrange(...)) will give the same results as range(...).
Georg is pretty much correct in his explanation, but just to dot all the
I's and cross all the
On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote:
> [EMAIL PROTECTED] wrote:
>> hi John,
>> Python doesn't provide for loop like C / C++ but using Range() or
>> Xrange() you can achive all the functionalities of the C for loop.
>
> Not quite.
Care to explain what the differences are,
On Wed, 05 Apr 2006 09:16:37 -0400, AndyL wrote:
> Paul Rubin wrote:
>> Normally you'd use range or xrange. range builds a complete list in
>> memory so can be expensive if the number is large. xrange just counts
>> up to that number.
>
> so when range would be used instead of xrange. if xrange
AndyL <[EMAIL PROTECTED]> wrote:
>Paul Rubin wrote:
>> Normally you'd use range or xrange. range builds a complete list in
>> memory so can be expensive if the number is large. xrange just counts
>> up to that number.
>so when range would be used instead of xrange. if xrange is more
>efficient,
On Tue, 2006-04-04 at 21:54 -0400, John Salerno wrote:
> I'm reading Text Processing in Python right now and I came across a
> comment that is helping me to see for loops in a new light. I think
> because I'm used to the C-style for loop where you create a counter
> within the loop declaration,
AndyL wrote:
> Paul Rubin wrote:
>> Normally you'd use range or xrange. range builds a complete list in
>> memory so can be expensive if the number is large. xrange just counts
>> up to that number.
>
> so when range would be used instead of xrange. if xrange is more
> efficient, why range was
[EMAIL PROTECTED] wrote:
> hi John,
> Python doesn't provide for loop like C / C++ but using Range() or
> Xrange() you can achive all the functionalities of the C for loop.
Not quite.
Georg
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> Normally you'd use range or xrange. range builds a complete list in
> memory so can be expensive if the number is large. xrange just counts
> up to that number.
so when range would be used instead of xrange. if xrange is more
efficient, why range was not reimplemented?
--
Roel Schroeven wrote:
> In many cases loops really are for iterating over sequences; more so
> than I realized when using for loops in C or C++. In these cases,
> Python's for statement works better than C-style loops. And if you
> really need to do something a certain number of times, there's
John Salerno schreef:
> I'm reading Text Processing in Python right now and I came across a
> comment that is helping me to see for loops in a new light. I think
> because I'm used to the C-style for loop where you create a counter
> within the loop declaration, for loops have always seemed to m
It's not just a Python thing, Java for example generally uses the
idiom:
for (Iterator it = list.iterator(); it.hasNext(); ) {
Object next = it.next();
//Do stuff to next
}
Horrible compared to the python idiom of course (though the latest
version supports for (x : list){})
Ruby has some
John Salerno wrote:
> The reason for this distinction comes from the fact that I read a lot
> how using range and for is somewhat discouraged, because it doesn't
> really use a for loop for it's true purpose. So my question is, is this
> just a Python-oriented opinion about for loops, or is it a ge
hi John,
Python doesn't provide for loop like C / C++ but using Range() or
Xrange() you can achive all the functionalities of the C for loop.If
you wants distributed for loop You can use Xrange.
John Salerno wrote:
> I'm reading Text Processing in Python right now and I came across a
> comment
John Salerno <[EMAIL PROTECTED]> writes:
> The reason for this distinction comes from the fact that I read a lot
> how using range and for is somewhat discouraged, because it doesn't
> really use a for loop for it's true purpose. So my question is, is
> this just a Python-oriented opinion about for
17 matches
Mail list logo