On 12/10/2013 12:46 AM, Steven D'Aprano wrote:
In Python 2.7, you can abbreviate that last one slightly:

'{} "{}"'.format(number, word)

Why 2.7? By me also works with 3.3.

Either should be preferred to building the string by hand with + signs.
The rule of thumb I use is to say that adding two substrings together is
fine, if I need more than one + sign I use a format string. So these
would be okay:

plural = word + "s"
line = sentence + '\n'

but anything more complex and I would use % or format().

That's also my rule, except if I use %-strings or format around, I also use it for a single, binary catenation.

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to