Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3513
| References | <BANLkTik3h6PP=3zenu+Deo+MAMN3jUTtxg@mail.gmail.com> |
|---|---|
| From | James Mills <prologic@shortcircuit.net.au> |
| Date | 2011-04-19 10:34 +1000 |
| Subject | Re: [Tutor] working with strings in python3 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.531.1303173290.9059.python-list@python.org> (permalink) |
On Tue, Apr 19, 2011 at 10:17 AM, Rance Hall <ranceh@gmail.com> wrote: > pseudo code: > > > message = "Bah." > > if test: > message = message + " Humbug!" > > print(message) > > end pseudo code Normally it's considered bad practise to concatenate strings. Use a a format specifier like this: > message = "Bah." > > if test: > message = "%s %s" (message, " Humbug!") > > print(message) Python3 (afaik) also introduced the .format(...) method on strings. cheers James -- -- James Mills -- -- "Problems are solved by method"
Back to comp.lang.python | Previous | Next — Next in thread | Find similar
Re: [Tutor] working with strings in python3 James Mills <prologic@shortcircuit.net.au> - 2011-04-19 10:34 +1000
Re: [Tutor] working with strings in python3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-19 02:16 +0000
Re: [Tutor] working with strings in python3 Chris Angelico <rosuav@gmail.com> - 2011-04-19 13:22 +1000
Re: [Tutor] working with strings in python3 Westley Martínez <anikom15@gmail.com> - 2011-04-18 20:26 -0700
csiph-web