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] Topic #2 of Tutor Digest

2012-07-28 Thread Alan Gauld
On 28/07/12 18:53, Todd Tabern wrote: Even if I were to purposefully ask the question in multiple places, > why does that concern you? I wasn't aware that asking for > help in multiple places is forbidden. Its not. But it is considered bad Netiquette. Its also likely to get you noticed as a "n

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] Topic #2 of Tutor Digest

2012-07-28 Thread Emile van Sebille
On 7/28/2012 10:53 AM Todd Tabern said... Even if I were to purposefully ask the question in multiple places, why does that concern you? wasn't aware that asking for help in multiple places is forbidden. It's not forbidden -- simply disrespectful. We all volunteer our available time to res

Re: [Tutor] Topic #2 of Tutor Digest

2012-07-28 Thread Todd Tabern
Mark Lawrence: Yes, I did... I kept encountering errors when trying to post the first time. I didn't think my question went through, so I tried this one. Even if I were to purposefully ask the question in multiple places, why does that concern you? I wasn't aware that asking for help in multiple

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] Encoding error when reading text files in Python 3

2012-07-28 Thread Dat Huynh
I change my code and it runs on Python 3 now. f = open(rootdir+file, 'rb') data = f.read().decode('utf8', 'ignore') Thank you very much. Sincerely, Dat. On Sat, Jul 28, 2012 at 6:09 PM, Steven D'Aprano wrote: > Dat Huynh wrote: >> >> Dear all, >> >> I have written a simp

Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Mark Lawrence
On 28/07/2012 02:38, Todd Tabern wrote: I'm looking to search an entire XML file for specific text and replace that text, while maintaining the structure of the XML file. The text occurs within multiple nodes throughout the file. I basically need to replace every occurrence C:\Program Files wit

Re: [Tutor] Encoding error when reading text files in Python 3

2012-07-28 Thread Steven D'Aprano
Dat Huynh wrote: Dear all, I have written a simple application by Python to read data from text files. Current I have both Python version 2.7.2 and Python 3.2.3 on my laptop. I don't know why it does not run on Python version 3 while it runs well on Python 2. Python 2 is more forgiving of beg

[Tutor] Encoding error when reading text files in Python 3

2012-07-28 Thread Dat Huynh
Dear all, I have written a simple application by Python to read data from text files. Current I have both Python version 2.7.2 and Python 3.2.3 on my laptop. I don't know why it does not run on Python version 3 while it runs well on Python 2. Could you please tell me how I can run it on python 3

Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Alan Gauld
On 28/07/12 02:38, Todd Tabern wrote: I'm looking to search an entire XML file for specific text and replace that text, > while maintaining the structure of the XML file. Do you mean the physical layout of the file or the technical XML structure? I'm assuming its the latter? If it's the forme

Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Bod Soutar
On Jul 28, 2012 2:39 AM, "Todd Tabern" wrote: > > I'm looking to search an entire XML file for specific text and replace that text, while maintaining the structure of the XML file. The text occurs within multiple nodes throughout the file. > I basically need to replace every occurrence C:\Program