Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread eryksun
On Sun, Jul 29, 2012 at 4:29 PM, Peter Otten <__pete...@web.de> wrote: > > If you have to sort your data anyway you can sort it first and then apply > itertools.groupby()... That was my thinking. I wrote it with groupby (see link below) because Francesco described field 0 as "in growing order". h

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Francesco Loffredo
Il 29/07/2012 03:42, Dave Angel wrote: On 07/28/2012 07:12 PM, Francesco Loffredo wrote: You might find it enlightening to look up: http://www.doughellmann.com/PyMOTW/ which explores the Pythons standard library. Site promptly visited, PDF downloaded, started reading. It really seems a

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Peter Otten
eryksun wrote: > On Sun, Jul 29, 2012 at 7:21 AM, Peter Otten <__pete...@web.de> wrote: >> >> If you don't have to deal with large datasets many of its functions can >> easily be emulated with lists and loops though. As an example here's the >> grouping with a plain vanilla dict: >> >> groups = {}

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread eryksun
On Sun, Jul 29, 2012 at 7:21 AM, Peter Otten <__pete...@web.de> wrote: > > If you don't have to deal with large datasets many of its functions can > easily be emulated with lists and loops though. As an example here's the > grouping with a plain vanilla dict: > > groups = {} > for item in data: >

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Mark Lawrence
On 29/07/2012 18:32, Alan Gauld wrote: On 29/07/12 15:21, Mark Lawrence wrote: Reminds me of the Welsh selectors, two were wise and chose Dai, but three were foolish and chose Gareth. That should lead to some head scratching!!! I'm scratching, but it sounds like a throwback to the 1980's nat

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Alan Gauld
On 29/07/12 15:21, Mark Lawrence wrote: Reminds me of the Welsh selectors, two were wise and chose Dai, but three were foolish and chose Gareth. That should lead to some head scratching!!! I'm scratching, but it sounds like a throwback to the 1980's national rugby team... Dai Jones and Gareth

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Mark Lawrence
On 29/07/2012 14:16, Alan Gauld wrote: On 29/07/12 12:21, Peter Otten wrote: plenty modules I haven't explored yet - and I must admit itertools is one that I really should get to grips with... You're nuts :) Itertools to me is the Swiss Army Knife If you don't have to deal with large data

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Alan Gauld
On 29/07/12 12:21, Peter Otten wrote: plenty modules I haven't explored yet - and I must admit itertools is one that I really should get to grips with... You're nuts :) Itertools to me is the Swiss Army Knife If you don't have to deal with large datasets many of its functions can easily be

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Peter Otten
Mark Lawrence wrote: > On 29/07/2012 00:53, Alan Gauld wrote: >> On 29/07/12 00:12, Francesco Loffredo wrote: >> >>> Every time this happens, I have to admit that I'm a newbie and I've >>> still got a lot to learn about Python. Especially about its wonderful >>> standard library. >> >> Don't worry

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Mark Lawrence
On 29/07/2012 00:53, Alan Gauld wrote: On 29/07/12 00:12, Francesco Loffredo wrote: Every time this happens, I have to admit that I'm a newbie and I've still got a lot to learn about Python. Especially about its wonderful standard library. Don't worry, I've been using Python for 15 years and

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread eryksun
On Sat, Jul 28, 2012 at 7:12 PM, Francesco Loffredo wrote: > > My bad, now I'll RTFM again and I will study very carefully the operator and > itertools modules. I forgot to mention a gotcha about groupby's implementation. The grouby object and the yielded _grouper objects share a single iterator.

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Dave Angel
On 07/28/2012 07:12 PM, Francesco Loffredo wrote: > Il 28/07/2012 20:41, eryksun wrote: >> On Sat, Jul 28, 2012 at 11:12 AM, Francesco Loffredo >> wrote: >>> I had to study carefully your present and desired lists, and I >>> understood >>> what follows (please, next time explain !): >>> - each 7-t

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Alan Gauld
On 29/07/12 00:12, Francesco Loffredo wrote: Every time this happens, I have to admit that I'm a newbie and I've still got a lot to learn about Python. Especially about its wonderful standard library. Don't worry, I've been using Python for 15 years and there are plenty modules I haven't explo

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 20:41, eryksun wrote: On Sat, Jul 28, 2012 at 11:12 AM, Francesco Loffredo wrote: I had to study carefully your present and desired lists, and I understood what follows (please, next time explain !): - each 7-tuple in your present list is a record for some measure relative to a pe

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 19:43, Steven D'Aprano wrote: Francesco Loffredo wrote: but I must avoid reading my function again, or I'll find some more bugs! Perhaps you should run your function, and test it. Of course I did. Just not as thoroughly as I would if this were a job commitment. Unfortunately, I

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread eryksun
On Sat, Jul 28, 2012 at 11:12 AM, Francesco Loffredo wrote: > > I had to study carefully your present and desired lists, and I understood > what follows (please, next time explain !): > - each 7-tuple in your present list is a record for some measure relative to > a person. Its fields are as follo

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Steven D'Aprano
Francesco Loffredo wrote: but I must avoid reading my function again, or I'll find some more bugs! Perhaps you should run your function, and test it. Finding bugs is not the problem. Once you find them, you can fix them. It is the bugs that you don't know about that is the problem. -- Ste

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 17:12, Francesco Loffredo ha scritto: Il 19/07/2012 19:33, PyProg PyProg ha scritto: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '1

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 19/07/2012 19:33, PyProg PyProg ha scritto: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', '7.5/10.0', '40.5/6

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-20 Thread Steven D'Aprano
PyProg PyProg wrote: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', '7.5/10.0', '40.5/60.0')] ... from this one:

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-19 Thread Prasad, Ramit
> I would get a new list as: > > [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', > '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', > '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', > '7.5/10.0', '40.5/60.0')] > > ... from this one: > > [(0, '3eA'

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-19 Thread शंतनू
You may use 'set'. e.g. === >>> x [(1, 2, 3), (1, 1), (2, 2), (1, 1), (2, 2)] >>> set(x) set([(2, 2), (1, 1), (1, 2, 3)]) === On 19-Jul-2012, at 11:03 PM, PyProg PyProg wrote: > Hi all, > > I would get a new list as: > > [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', >

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-19 Thread PyProg PyProg
Oh I forgot to mention, with Python 2 (2.7). -- http://ekd.tuxfamily.org http://ekdm.wordpress.com http://glouk.legtux.org/guiescputil http://lcs.dunois.clg14.ac-caen.fr/~alama/blog http://lprod.org/wiki/doku.php/video:encodage:avchd_converter ___ Tutor

[Tutor] Flatten a list in tuples and remove doubles

2012-07-19 Thread PyProg PyProg
Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', '7.5/10.0', '40.5/60.0')] ... from this one: [(0, '3eA', 'Dupont',