python string, best way to concat

Marko Rauhamaa marko at pacujo.net
Thu Aug 28 04:34:43 EDT 2014


peter <peter.mosley at talk21.com>:

> Obviously this isn't going to change, but for concatenating short
> strings a and b is there any practical reason to avoid a+b?

Often, no. The biggest penalty is visual. For example, I would prefer
this:

    "{}/{}".format(prefix, suffix)

over

    prefix + "/" + suffix


Really, I would and do.


Marko




More information about the Python-list mailing list