Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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; 'that?': 0.05; 'subject:PEP': 0.07; 'string': 0.09; 'arguments': 0.09; 'converted': 0.09; 'formatting': 0.09; 'pep': 0.09; 'def': 0.12; 'argument,': 0.16; 'operator.': 0.16; 'specifier': 0.16; 'tuple': 0.16; 'tuple.': 0.16; 'typeerror:': 0.16; "why's": 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; '(by': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'skip:- 40': 0.29; 'am,': 0.29; "doesn't": 0.30; '"",': 0.31; 'file': 0.32; 'another': 0.32; '(most': 0.33; 'trouble': 0.34; 'date:': 0.34; 'email addr:python.org': 0.37; 'handle': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 're:': 0.63; 'email name:python-list': 0.65; 'design.': 0.68; 'received:74.208': 0.68; "'2'": 0.84; 'received:74.208.4.194': 0.84; 'carlos': 0.91; '2013': 0.98 Date: Thu, 23 May 2013 14:42:47 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: PEP 378: Format Specifier for Thousands Separator References: , , , , , , , , , , , , , , <519c348a$0$6599$c3e8da3$5496439d@news.astraweb.com>, , <519C3D99.5040107@gmail.com>, , , , <519cdcff$0$6599$c3e8da3$5496439d@news.astraweb.com>, , , , <87eaaf24-df6a-4f6b-b873-16ca96c12e24@b2g2000yqe.googlegroups.com>, , In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:yRJJXEb7zN1BBgSbJuVbuJ15inrkXrNZDNnt2FtjB3y f/BvatdWQyVf5pfwAz+y92E5rtsKhNc7EfEpp3crhbp/ziCcrF P2x7F6yevJBZw7LNqAJlZKqQzxYhUYUVZ75wG7GhyB2ya2XIfU jKMn0vaFxUtS0fZBOGE+rjlu3TJI7uD/T6hyy8n9aCdcB2ydJ/ RCjupmBftftYXOTnPALAoSPUDgEX8FWyuy85Q9j8+KcnyPVnYf 8y15kPNH55mNJnNf8OC0i/a2DGbeGGU4aaAFBcmqIPuezzDe1M uRCE7w5nkOP4TAJpPq6Ur8yUmNu7OpHi1VrIImqkDqe3Q3khZH YMrlfDP54qRThyVfe1bg= 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369334586 news.xs4all.nl 15905 [2001:888:2000:d::a6]:43048 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45832 On 05/23/2013 11:26 AM, Carlos Nepomuceno wrote: > ---------------------------------------- >> Date: Thu, 23 May 2013 06:44:05 -0700 >> Subject: Re: PEP 378: Format Specifier for Thousands Separator >> From: pruebauno@latinmail.com >> To: python-list@python.org > [...] You left out the part where a and f are initialized: >>> a='%s' >>> f=(3,5) >>>>> eggs(a,f) >> Traceback (most recent call last): >> File "", line 1, in >> eggs(a,f) >> File "", line 1, in eggs >> def eggs(spam, ham): return spam % ham >> TypeError: not all arguments converted during string formatting >>>>> '%s'%(5%3) >> '2' > > So % doesn't handle tuples! Why's that? Is it intentional (by design)? > It's a conflict in the design. A tuple is used to supply multiple arguments to the % operator. So if you want to have a tuple as the first argument, you need to enclose it in another tuple. try the following: print a % (f,) The trouble is, it doesn't generalize very readily, so it's difficult to use in a function like eggs() -- DaveA