Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'msg': 0.09; 'skip:% 20': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'wrote': 0.14; 'splitting': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'points': 0.29; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'along': 0.30; 'lines': 0.31; 'gary': 0.31; 'really,': 0.31; "i'd": 0.34; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:" 50': 0.36; 'should': 0.36; 'pm,': 0.38; 'how': 0.40; 'of:': 0.68; 'clearer': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Rn9HsQbtreo2UsBUt9ccUiIYTP6oxPYFb9liuoaRAQM=; b=JCcmSLuNqBj69ZZCO3SMQjXuPoKq8wpUDVrrwKyReeUzAg4vKbmHWrEzMK7y/2fcus lkuB6L3EK6PtizNaA4tJ4CPzYFJy1STvExc7/WGi8mXFgvhTTQ7Hc0+TurEw3cNvWqdK etIomXnftRTdMrTjvGIBSpnUS6wDmi0u5IJacydhdjyX3G5VqIQjOaqqEOKMV4zufXX4 VzCJqskdUvHPRkadT5E1w402yH/huzv15emmEO92hHwSh6RJyxeeKwo7y3XUzNUG0S34 F2MGDmv9SSMLi+Jh406Jjqac40YWblebY3FAFBFqY2/UHv/ZYHWVNvPboJysKI3okC/y 1CaA== X-Received: by 10.152.4.232 with SMTP id n8mr7957727lan.29.1371908244057; Sat, 22 Jun 2013 06:37:24 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <51C4D2FF.8000709@digipen.edu> References: <51C4D2FF.8000709@digipen.edu> From: Joshua Landau Date: Sat, 22 Jun 2013 14:36:43 +0100 Subject: Re: n00b question on spacing To: Gary Herron Content-Type: text/plain; charset=UTF-8 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371908252 news.xs4all.nl 15887 [2001:888:2000:d::a6]:43683 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48922 On 21 June 2013 23:26, Gary Herron wrote: > On 06/21/2013 02:17 PM, Yves S. Garret wrote: >> I have the following line of code: >> log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], >> settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) <...> >> I was thinking of splitting it up like so: >> log.msg("Item wrote to MongoDB database %s/%s" >> %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), >> level=log.DEBUG, spider=spider) > > This is how I'd do it: (And it's *FAR* clearer -- You win no points for > clarity by having it all in one statement.) > > fmt = "Item wrote to MongoDB database %s/%s" > msg = fmt % (settings['MONGODB_DB'], > settings['MONGODB_COLLECTION']) > log.msg(msg, level=log.DEBUG, spider=spider) Hear, Hear. But really, you should be using .format by now :P My favourite way would be along the lines of: message = "Item wrote to MongoDB database " message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings) log.msg(message, level=log.DEBUG, spider=spider)