Hmm... I thought this issue is available from Python2.5 only. I have
no other interpreters in my recently installed KUBUNTU 8.04.

Thanks all,
D.

On 9 Тра, 13:41, Duncan Booth <[EMAIL PROTECTED]> wrote:
> dmitrey <[EMAIL PROTECTED]> wrote:
> > On 9 ôÒÁ, 13:17, Paul Hankin <[EMAIL PROTECTED]> wrote:
> >> On May 9, 11:04šam, dmitrey <[EMAIL PROTECTED]> wrote:
>
> >> > list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5']
> >> > and
> >> > list2 = [0, 2, 4] # integer elements
>
> >> > howto (I mean most simple recipe, of course) form list3 that contains
> >> > elements from list1 with indexes from list2, i.e.
>
> >> list3 = [list1[i] for i in list2]
>
> > Ok, I use Python 2.5 but I try my code to remain Python 2.4 and
> > (preferable) 2.3 compatible.
> > Are there other solutions?
> > D.
>
> Did you try Paul's suggestion?
>
> Python 2.3.5 (#1, Oct 13 2005, 09:17:23)
> [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5']
> >>> list2 = [0, 2, 4]
> >>> list3 = [list1[i] for i in list2]
> >>> list3
>
> ['elem0', 'elem2', 'elem4']

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to