Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; '%s"': 0.09; 'subject:Tutor': 0.09; 'to:name:python list': 0.09; 'this:': 0.11; 'am,': 0.14; 'wrote:': 0.14; '"%s': 0.16; '10:17': 0.16; 'specifier': 0.16; 'subject:] ': 0.16; 'tue,': 0.20; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'message-id:@mail.gmail.com': 0.28; 'hall': 0.29; 'solved': 0.31; 'strings.': 0.31; 'subject:working': 0.31; 'to:addr:python-list': 0.32; 'normally': 0.35; 'considered': 0.36; 'subject:with': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'code:': 0.38; 'end': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'received:74.125.83': 0.69; 'concatenate': 0.84 MIME-Version: 1.0 In-Reply-To: References: From: James Mills Date: Tue, 19 Apr 2011 10:34:27 +1000 Subject: Re: [Tutor] working with strings in python3 To: python list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303173290 news.xs4all.nl 81485 [::ffff:82.94.164.166]:39309 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3513 On Tue, Apr 19, 2011 at 10:17 AM, Rance Hall wrote: > pseudo code: > > > message =3D "Bah." > > if test: > =C2=A0 message =3D message + " Humbug!" > > print(message) > > end pseudo code Normally it's considered bad practise to concatenate strings. Use a a format specifier like this: > message =3D "Bah." > > if test: > =C2=A0 message =3D "%s %s" (message, " Humbug!") > > print(message) Python3 (afaik) also introduced the .format(...) method on strings. cheers James --=20 -- James Mills -- -- "Problems are solved by method"