Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'operator': 0.03; 'messages.': 0.04; 'debug': 0.05; 'method.': 0.05; 'python': 0.09; 'logic': 0.09; 'looked': 0.10; 'slightly': 0.15; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'statement;': 0.16; '{1},': 0.16; 'string': 0.17; 'wrote:': 0.17; 'preferred': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'topic': 0.27; 'lines': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'strings,': 0.29; '"the': 0.29; 'initially': 0.30; 'function': 0.30; 'print': 0.32; 'anywhere': 0.33; 'function.': 0.33; 'to:addr:python-list': 0.33; 'subject:?': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'skip:{ 10': 0.36; 'two': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'real': 0.61; 'worth': 0.63; 'more': 0.63 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Sat, 23 Mar 2013 09:57:48 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: how does the % work? References: <7qbqk8p64dp4v2qvgfogvigi91gjdt5k3r@4ax.com> <514d5bef$0$30001$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <514d5bef$0$30001$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364054284 news.xs4all.nl 6851 [2001:888:2000:d::a6]:45579 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41741 On 03/23/2013 01:38 AM, Steven D'Aprano wrote: > Just to add confusion, the two lines are exactly the same in Python 2, > where Print is not a function! Perhaps this is a good reason use the slightly more complicated but easier to get right format method. print ("{0}, {1}, {2}".format(1,2,3)) And it's worth noting that using the string formatter or the old % operator on a string works anywhere where there're strings, not just in the print function. b = "The answer was %d" % answer or b = "The answer was {0}".format(answer) On the topic of print, I can see the logic in print being a function now, but I have always preferred it as a print statement; it just looked cleaner. That was one of the things that initially attracted me to python. But the reality is print isn't used for much in real programs other than console debug messages.