[Tutor] Concatenating Strings

Steven D'Aprano steve at pearwood.info
Tue May 29 08:06:57 CEST 2012


On Tue, May 29, 2012 at 03:51:21PM +1000, Steven D'Aprano wrote:

> > Using + is arguably preferable when you have a choice to make, since it 
> > works in all cases, including constants.
> 
> I'll argue differently: even though + works with string literals as well 
> as variables, you shouldn't use it.

Oops, that sentence is unclear -- what I meant is that you shouldn't use 
+ to concatenate two string literals, not that you should never use it 
at all! When you have one or both are variables, you MUST use + rather 
than implicit concatenation.

Sorry for any confusion.


-- 
Steven


More information about the Tutor mailing list