Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Spyros Charonis
FINAL SOLUTION: ### LOOP OVER DIRECTORY location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels' zdata = [] for filename in os.listdir(location): filename = os.path.join(location, filename) try: zdata.extend(extract_zcoord(filename)) except NameError: print No such file! except

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Steven D'Aprano
On Wed, May 30, 2012 at 07:00:30AM +0100, Spyros Charonis wrote: FINAL SOLUTION: Not quite. You are making the mistake of many newbies to treat Python exceptions as a problem to be covered up and hidden, instead of as a useful source of information. To quote Chris Smith: I find it

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Spyros Charonis
On Wed, May 30, 2012 at 8:16 AM, Steven D'Aprano st...@pearwood.infowrote: On Wed, May 30, 2012 at 07:00:30AM +0100, Spyros Charonis wrote: FINAL SOLUTION: Not quite. You are making the mistake of many newbies to treat Python exceptions as a problem to be covered up and hidden, instead of

[Tutor] Joining all strings in stringList into one string

2012-05-30 Thread Akeria Timothy
Hello all, I am working on learning Python(on my own) and ran into an exercise that I figured out but I wanted to know if there was a different way to write the code? I know he wanted a different answer for the body because we haven't gotten to the ' '.join() command yet. This is what I have:

Re: [Tutor] Joining all strings in stringList into one string

2012-05-30 Thread Glen Zangirolami
Seems like a lot of extra work for joining the strings. You should only need: ''.join(['very', 'hot', 'day']) (no spaces) ' '.join(['very', 'hot', 'day']) (if you want spaces) glen On Wed, May 30, 2012 at 11:21 AM, Akeria Timothy akeriatimo...@gmail.comwrote: Hello all, I am working on

Re: [Tutor] Joining all strings in stringList into one string

2012-05-30 Thread Dave Angel
On 05/30/2012 12:21 PM, Akeria Timothy wrote: Hello all, I am working on learning Python(on my own) and ran into an exercise that I figured out but I wanted to know if there was a different way to write the code? I know he wanted a different answer for the body because we haven't gotten to

Re: [Tutor] Joining all strings in stringList into one string

2012-05-30 Thread bob gailer
On 5/30/2012 12:21 PM, Akeria Timothy wrote: In addition to the other comments I point out that join is not a /command/, it is a /string method/. Python does not have commands. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist -

Re: [Tutor] Joining all strings in stringList into one string

2012-05-30 Thread Russel Winder
On Wed, 2012-05-30 at 12:21 -0400, Akeria Timothy wrote: [...] def joinStrings(stringList): string = [] indentation error in that the above line and the below line should have the same indent level. Also the above line and the following line are both definitions of the variable string so the

Re: [Tutor] Joining all strings in stringList into one string

2012-05-30 Thread Dave Angel
A procedural point here: You forgot to include the list, and just replied to me privately. Normally, what you should do is a Reply-All. Or else make sure tutor@python.org is one of the To: or CC: list On 05/30/2012 01:40 PM, Akeria Timothy wrote: I did copy and paste and I'm learning

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Steven D'Aprano
Spyros Charonis wrote: On Wed, May 30, 2012 at 8:16 AM, Steven D'Aprano st...@pearwood.infowrote: [...] There is little as painful as a program which prints An error occurred and then *keeps working*. What does this mean? Can I trust that the program's final result is correct? How can it be