Why it is so dramatical?

Max M maxm at mxm.dk
Tue Sep 3 11:05:23 CEST 2002


Bo M. Maryniuck wrote:
> On Monday 02 September 2002 05:47, Jay O'Connor wrote:
> 
>>As a result Perl is much faster at some kinds of operations than
>>Python, and vice-versa.
> 
> 
> Yeah, actually, but I just would like to find some optimal Python solution :)


Actually it is possible to make it as readable as concatenation with:

result = []
a = result.append

a('some string')
a('another string')
a('third string')
for letter in 'abcdefghijklmnop':
     a(letter)

result = ''.join(result)


rather than:

result = ''
result += 'some string'
result += 'another string'
result += 'third string'
for letter in 'abcdefghijklmnop':
     result += letter


regards Max M




More information about the Python-list mailing list