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't know how much
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 you've had,
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 other).
Thank
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 don't want to. I want it to
stay exactly the same
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 to
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 want to start
Thanks! I knew it was simple...
--
http://mail.python.org/mailman/listinfo/python-list
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 don't want to. I want it to
stay exactly the same
[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--) {
do_stuff()
}
I mean, I could reverse the list, but I don't want to. I
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()
So, to go
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 don't want to. I want it to
stay exactly the same
11 matches
Mail list logo