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

2012-06-06 Thread Steven D'Aprano
Prasad, Ramit wrote: But more importantly, some years ago (Python 2.4, about 8 years ago?) the Python developers found a really neat trick that they can do to optimize string concatenation so it doesn't need to repeatedly copy characters over and over and over again. I won't go into details, but

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

2012-06-04 Thread Prasad, Ramit
> But more importantly, some years ago (Python 2.4, about 8 years ago?) the > Python developers found a really neat trick that they can do to optimize > string concatenation so it doesn't need to repeatedly copy characters over > and > over and over again. I won't go into details, but the thing is,

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

2012-06-02 Thread Jordan
Thanks for the excellent feedback and very informative. I guess I just did not consider the memory side of things and did not think about just how much extra addition was having to occur. Additionally I also found this supporting link: http://wiki.python.org/moin/PythonSpeed/PerformanceTips#String_

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

2012-06-02 Thread Steven D'Aprano
Jordan wrote: #Another version might look like this: def join_strings2(string_list): final_string = '' for string in string_list: final_string += string print(final_string) return final_string Please don't do that. This risks becoming slow. REALLY slow. Painfully slow.

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

2012-06-02 Thread Jordan
On 05/30/2012 06: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 gott

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 Pyth

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 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 - Tutor@p

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

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 wrote: > Hello all, > > I am working on learning Python(on my ow