Re: Loop Backwards

2006-03-17 Thread john_sips_tea
Tim Roberts wrote: > "Dave" <[EMAIL PROTECTED]> wrote: > > > >Please be mindful of making statements such as: > >"it's silly to believe both will behave equally" > > > >One of the greatest weaknesses of Python is the less than friendly > >attitude Pythonistas display towards one another. > > I don

Re: Loop Backwards

2006-03-16 Thread Tim Roberts
"Dave" <[EMAIL PROTECTED]> wrote: > >Please be mindful of making statements such as: >"it's silly to believe both will behave equally" > >One of the greatest weaknesses of Python is the less than friendly >attitude Pythonistas display towards one another. I don't know how much Usenet experience yo

Re: Loop Backwards

2006-03-15 Thread Dave
>> or (more perlish at first sight): >> for item in alist[::-1]: >> do_something_with(item) >No "or" here. The [::-1] version creates a whole new list in memory, >it's silly to believe both will behave equally (well, strictly speaking >they will, but one will use twice more memory than the othe

Re: Loop Backwards

2006-02-14 Thread Felipe Almeida Lessa
Em Ter, 2006-02-14 às 10:08 +0100, bruno at modulix escreveu: > for item in reversed(alist): > do_something_with(item) > > or (more perlish at first sight): > > for item in alist[::-1]: > do_something_with(item) No "or" here. The [::-1] version creates a whole new list in memory, it's silly

Re: Loop Backwards

2006-02-14 Thread bruno at modulix
Dave wrote: > This should be simple, but I can't get it: > > How do you loop backwards through a list? > > For example, in, say, Javascript: > > for (var i = list.length - 1; i >=0; i--) { > do_stuff() > } > > I mean, I could reverse the list,

Re: Loop Backwards

2006-02-13 Thread [EMAIL PROTECTED]
Dave wrote: > This should be simple, but I can't get it: > > How do you loop backwards through a list? > > For example, in, say, Javascript: > > for (var i = list.length - 1; i >=0; i--) { > do_stuff() > } > > I mean, I could reverse the list, but I d

Re: Loop Backwards

2006-02-13 Thread skip
Dave> This should be simple, but I can't get it: Dave> How do you loop backwards through a list? Standard idiom: for i in range(len(mylist)-1, -1, -1): do_stuff() Contrast that with the standard forward loop: for i in range(len(mylist)): do_stuff()

Re: Loop Backwards

2006-02-13 Thread bonono
[EMAIL PROTECTED] wrote: > Dave wrote: > > This should be simple, but I can't get it: > > > > How do you loop backwards through a list? > > > > For example, in, say, Javascript: > > > > for (var i = list.length - 1; i >=0; i--) { > >

Re: Loop Backwards

2006-02-13 Thread Carl Cerecke
Dave wrote: > This should be simple, but I can't get it: > > How do you loop backwards through a list? > > For example, in, say, Javascript: > > for (var i = list.length - 1; i >=0; i--) { > do_stuff() > } > > I mean, I could reverse the list,

Re: Loop Backwards

2006-02-13 Thread Dave
Thanks! I knew it was simple... -- http://mail.python.org/mailman/listinfo/python-list

Loop Backwards

2006-02-13 Thread Dave
This should be simple, but I can't get it: How do you loop backwards through a list? For example, in, say, Javascript: for (var i = list.length - 1; i >=0; i--) { do_stuff() } I mean, I could reverse the list, but I don't want to. I want it to stay exactly the same, but I wan