[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Demexp-dev] Questions
From: |
David MENTRE |
Subject: |
Re: [Demexp-dev] Questions |
Date: |
Thu, 18 Oct 2007 18:02:02 +0200 |
Hi Lyu,
2007/10/18, Lyu Abe <address@hidden>:
> Is there a very simple way of addressing elements in a
> reversed way in a list?
Yep, use [::-1] operator ([:] operator with a negative step):
>>> l=[1,2,3,4]
>>> for i in l[::-1]:
print i
4
3
2
1
Explanation in the Python library doc: http://docs.python.org/lib/typesseq.html
The Python doc (http://docs.python.org/) is very useful. Most of the
time, the thing you are looking for are either in the Language
Reference (http://docs.python.org/ref/ref.html) or in the Library
Reference (http://docs.python.org/lib/lib.html).
BTW, please note that there is no guarantee of the demexp server to
sort the list in a specific order (the current reverse order comes
from the current sequence of processing in the server, that might
change in the future). Each question contains its question number
(parameter q_id, qu['q_id'] in your code) and you should sort the list
according to that.
Yours,
d.
- Re: [Demexp-dev] Questions, (continued)
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/15
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/16
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/16
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/17
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/17
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/17
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/17
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/18
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/18
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/18
- Re: [Demexp-dev] Questions,
David MENTRE <=
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/18
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/18
- Re: [Demexp-dev] Questions, Lyu Abe, 2007/10/20
- Message not available
- Re: [Demexp-dev] Questions, David MENTRE, 2007/10/16