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
"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
>> 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
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
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,
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
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()
[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--) {
> >
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,
Thanks! I knew it was simple...
--
http://mail.python.org/mailman/listinfo/python-list
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
11 matches
Mail list logo