Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Rich Lovely
2009/9/13 Lie Ryan : > Wayne wrote: >> >> Hi, >> >> I have a set of data that looks something like this: >> >> 3, 4, 3, 2, 1 >> 2, 1, 1, 1, 1 >> 4, 2, 2, 1, 2 >> 1, 3, 1, 1, 1 >> >> I want to be able to sort it by the first column, keeping the rest of the >> values in the same position relative to

Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Wayne
On Sun, Sep 13, 2009 at 7:27 AM, Rich Lovely wrote: > 2009/9/13 Lie Ryan : > > Wayne wrote: > >> > > if your data is like this: > > mylist = [ > >[3, 2, 4, 1], > >[4, 1, 2, 3], > >[3, 1, 2, 1], > >[2, 1, 1, 1], > >[1, 1, 2, 1], > > ] > > > > you can use zip(*mylist) to transfo

[Tutor] Still Trying to Understand GAE

2009-09-13 Thread ad...@gg-lab.net
Hi All, i've started earning python sone months ago (on Google App Engine unfortunately). I have some doubts reagrding "import", and have asked a similar question here months ago, but without finding a solution. So: with import i can import modules or single functions. And this is ok. Then: as

Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Kent Johnson
On Sun, Sep 13, 2009 at 1:17 AM, Lie Ryan wrote: > if you have data like this: > mylist = [ >    [3, 4, 3, 2, 1], >    [2, 1, 1, 1, 1], >    [4, 2, 2, 1, 2], >    [1, 3, 1, 1, 1], > ] > > you can use mylist.sort(key=lambda x: x[0]) You can omit the key parameter completely in this case, unless yo

Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Dirk Wangsadirdja
Lie Ryan wrote: if you have data like this: mylist = [ [3, 4, 3, 2, 1], [2, 1, 1, 1, 1], [4, 2, 2, 1, 2], [1, 3, 1, 1, 1], ] you can use mylist.sort(key=lambda x: x[0]) sorted(mylist, key=lambda x: x[0]) works as well if you need a new list I have a further question. If I wa

Re: [Tutor] Still Trying to Understand GAE

2009-09-13 Thread wesley chun
hi Giorgio, welcome to Python (whether directly or from GAE!) :-) my comments below. > with import i can import modules or single functions. And this is ok. not quite true. regardless of whether you use import or from-import, you're *always* importing (and loading) modules or packages in their

Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Patrick Sabin
> But for sorting the list with the first element as key, I tried it using just mylist.sort() without the lambda, and its working also. Then why use the lambda? There is a little difference between those two variations. Example: >>> sorted([[1,2],[1,3],[1,1]]) [[1, 1], [1, 2], [1, 3]] >>> s

Re: [Tutor] include remote module

2009-09-13 Thread Eike Welk
On Saturday 12 September 2009, Patrick wrote: > Imagine if I gave a client a live Linux CD that automatically > called this sort of script right after boot up. They could have the > absolute most current version of an application from my server > launched on their box and if their data from that ap

[Tutor] (no subject)

2009-09-13 Thread shellc...@juno.com
I want to take two tuples and and print out all the elements in both tuples Best Weight Loss Program - Click Here! http://thirdpartyoffers.juno.com/TGL2141/fc/BLSrjpTFoYayK1TMy2HLJuXWZVUVwGcRz3BvRi27bhNCVhUuOvezC0KPl88/ _

Re: [Tutor] (no subject)

2009-09-13 Thread bhaaluu
Go for it! 8^D On Sun, Sep 13, 2009 at 7:45 PM, shellc...@juno.com wrote: > I want to take two tuples and and print out all the elements in both tuples > > > Best Weight Loss Program - Click Here! > http://thirdpartyoffers.juno.com/TGL2

Re: [Tutor] (no subject)

2009-09-13 Thread bob gailer
Please provide a meaningful subject (other than no subject) shellc...@juno.com wrote: I want to take two tuples and and print out all the elements in both tuples Please explain your goals more thoroughly. A trivial answer to your question is: tuple1 = (2.3) tuple2 = (3,4) print tuple1, t