Using + with strings considered bad

Mark Lawrence breamoreboy at
Wed Apr 29 11:08:41 CEST 2015

On 29/04/2015 09:29, Cecil Westerhof wrote:
> Because I try to keep my lines (well) below 80 characters, I use the
> following:
>      print('Calculating fibonacci and fibonacci_memoize once for ' +
>            str(large_fibonacci) + ' to determine speed increase')
> But I was told that using + with strings was bad practice. Is this
> true? If so, what is the better way to do this?

It's not bad practice as such, it's simply that performance takes a nose 
dive if you're contatenating large numbers of strings.  If performance 
is an issue the recommended way is to write.

' '.join(strings)

My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

More information about the Python-list mailing list