Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45832
| Date | 2013-05-23 14:42 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: PEP 378: Format Specifier for Thousands Separator |
| References | <b8623121-631a-4464-bd23-0e210018de78@e13g2000yqp.googlegroups.com> <BLU176-W35FCA0F6068A230026ED88D7AA0@phx.gbl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2028.1369334586.3114.python-list@python.org> (permalink) |
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 "<pyshell#29>", line 1, in <module> >> eggs(a,f) >> File "<pyshell#1>", 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: PEP 378: Format Specifier for Thousands Separator Andrew Berg <bahamutzero8825@gmail.com> - 2013-05-21 14:53 -0500
Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 02:59 +0000
Re: PEP 378: Format Specifier for Thousands Separator Andrew Berg <bahamutzero8825@gmail.com> - 2013-05-21 22:38 -0500
Re: PEP 378: Format Specifier for Thousands Separator Skip Montanaro <skip@pobox.com> - 2013-05-22 05:45 -0500
Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 14:58 +0000
Re: PEP 378: Format Specifier for Thousands Separator Ned Batchelder <ned@nedbatchelder.com> - 2013-05-22 14:30 -0400
Re: PEP 378: Format Specifier for Thousands Separator nn <pruebauno@latinmail.com> - 2013-05-22 13:26 -0700
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-23 01:31 +0300
Re: PEP 378: Format Specifier for Thousands Separator nn <pruebauno@latinmail.com> - 2013-05-23 06:44 -0700
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-23 18:26 +0300
Re: PEP 378: Format Specifier for Thousands Separator Dave Angel <davea@davea.name> - 2013-05-23 14:42 -0400
Re: PEP 378: Format Specifier for Thousands Separator nn <pruebauno@latinmail.com> - 2013-05-24 06:50 -0700
Re: PEP 378: Format Specifier for Thousands Separator Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-23 16:19 -0400
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 01:20 +0300
Re: PEP 378: Format Specifier for Thousands Separator Jerry Hill <malaclypse2@gmail.com> - 2013-05-23 21:17 -0400
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 04:41 +0300
Re: PEP 378: Format Specifier for Thousands Separator Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-23 01:30 +0100
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-23 03:44 +0300
csiph-web