Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'preferably': 0.03; '(especially': 0.07; 'formatting': 0.07; 'pep': 0.07; 'something,': 0.07; 'python': 0.08; 'subject:string': 0.09; 'syntax': 0.11; 'received:209.85.214.174': 0.13; 'received:mail- iw0-f174.google.com': 0.13; 'wrote:': 0.15; 'caveat': 0.16; 'finney': 0.16; 'formatting.': 0.16; 'obviously,': 0.16; 'subject:formatting': 0.16; 'subject:vs.': 0.16; 'pm,': 0.16; 'meant': 0.17; 'thanks,': 0.17; 'variable': 0.21; 'header:In- Reply-To:1': 0.22; 'fine,': 0.23; 'indentation': 0.23; 'code': 0.24; 'times,': 0.25; 'string': 0.26; '(and': 0.27; "i'm": 0.27; '(the': 0.28; 'received:209.85.214': 0.28; 'code,': 0.29; 'kelly': 0.30; 'looks': 0.30; 'least': 0.31; 'lines': 0.31; 'change.': 0.32; 'team,': 0.32; 'message-id:@gmail.com': 0.32; 'it.': 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; '(as': 0.34; 'quite': 0.34; 'things': 0.34; 'agree': 0.35; 'explicit': 0.35; "isn't": 0.35; 'probably': 0.35; 'equal': 0.35; 'certain': 0.36; 'idea': 0.36; 'everyone.': 0.37; 'unless': 0.37; 'some': 0.37; 'but': 0.37; 'using': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'received:192.168.1': 0.39; 'should': 0.39; 'ways': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'subject:. ': 0.66; 'noise': 0.67; 'roughly': 0.67; 'dealing': 0.69; '05:59': 0.84; 'are)': 0.84; 'clearer': 0.84; 'one).': 0.84; 'zen': 0.84; 'contrast': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=XWqpCfU3q/pgq16Q7TPR54Y3Fgjz/E74Ym00Cm3LaW0=; b=FI00vLYC8Zma0T9BonTfRqRINR3ow0peBp5K5ExrXIpnEj3dNxP6OJVIb6fXSo+hss dBUykALefLHONh2KfQ5BfYBRAvX8v2XgHAa3YzPi3EQXm2fT0pO+ndcwNk8R2Q+JeqJS Mzdzl0Q5o8OX2kmiMIacjs72eb7OOZd4g69U4= Date: Fri, 08 Jul 2011 18:29:40 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: String concatenation vs. string formatting References: <877h7sidjq.fsf@benfinney.id.au> In-Reply-To: <877h7sidjq.fsf@benfinney.id.au> X-Enigmail-Version: 1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310167795 news.xs4all.nl 21779 [2001:888:2000:d::a6]:37335 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9100 On 2011.07.08 05:59 PM, Ben Finney wrote: > With the caveat that the formatting of that line should be using PEP 8 > indentation for clarity: PEP 8 isn't bad, but I don't agree with everything in it. Certain lines look good in chunks, some don't, at least to me. It's quite likely I'm going to be writing 98%, if not more, of this project's code, so what looks good to me matters more than a standard (as long as the code works). Obviously, if I need to work in a team, then things change. > > and when a variable is used a bunch of times, concatenation is fine, I prefaced that sentence with "Other than the case", as in "except for the following case(s)". > There is often more than one way to do it. The Zen of Python is explicit > that there should be one obvious way to do it (and preferably only one). I meant in contrast to the idea of intentionally having multiple ways to do something, all with roughly equal merit. On 2011.07.08 04:38 PM, Ian Kelly wrote: > Also, string formatting (especially using the new syntax like you are) > is much clearer because there's less noise (the quotes all over the > place and the plusses) I don't find it that much clearer unless there are a lot of chunks. > and it's better for dealing with internationalization if you need to > do that. I hadn't thought of that. That's probably the best reason to use string formatting. Thanks, everyone.