Dinesh B Vadhia wrote:
Thanks Steve. How do you sort on the second element of each list to get:
a' = [[42, 'fish'],
[1, 'hello']
[2, 'world']
]
something like this would do the trick:
a_prime = sorted(a, key=(lambda i: i[1]))
sorted(a) returns a new list consisting o
Thanks Steve. How do you sort on the second element of each list to get:
a' = [[42, 'fish'],
[1, 'hello']
[2, 'world']
]
From: Steve Willoughby
Sent: Monday, September 22, 2008 8:16 PM
To: Dinesh B Vadhia
Cc: tutor@python.org
Subject: Re: [Tutor] array of different
Dinesh B Vadhia wrote:
I have looked (honestly!) and cannot see an array structure to allow different datatypes per column. I need a 2 column array with column 1 = an integer and column 2 = chars, and after populating the array, sort on column 2 with column 1 sorted relatively.
If by "array"
I have looked (honestly!) and cannot see an array structure to allow different
datatypes per column. I need a 2 column array with column 1 = an integer and
column 2 = chars, and after populating the array, sort on column 2 with column
1 sorted relatively.
Thanks!
Dinesh
Download links...
1) Think Python (about 240 pages)--Allen Downey and
http://www.greenteapress.com/thinkpython/thinkpython.html
> 2) A Byte of Python (about 100 pages)
http://www.swaroopch.com/notes/Python#Download
On Sun, 2008-09-21 at 16:31 -0400, Robert Berman wrote:
> First, thank y
On 9/22/08, Tasos Latsas <[EMAIL PROTECTED]> wrote:
> Hello list,
> I tried the optparse example from the python library reference and it
> doesn't seem to work..what am I doing wrong?
> I keep getting the "incorrect number of arguments" message although i
> use the correct number..
Actually, you
On Mon, Sep 22, 2008 at 7:16 AM, Tasos Latsas <[EMAIL PROTECTED]> wrote:
> Hello list,
> I tried the optparse example from the python library reference and it
> doesn't seem to work..what am I doing wrong?
> I keep getting the "incorrect number of arguments" message although i
> use the correct num
Hello list,
I tried the optparse example from the python library reference and it
doesn't seem to work..what am I doing wrong?
I keep getting the "incorrect number of arguments" message although i
use the correct number..
The example is here :
http://docs.python.org/lib/optparse-putting-it-all-tog