Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45848

RE: PEP 378: Format Specifier for Thousands Separator

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <carlosnepomuceno@outlook.com>
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; '*not*': 0.07; 'binary': 0.07; 'subject:PEP': 0.07; 'string': 0.09; 'arguments': 0.09; 'formatting': 0.09; 'function,': 0.09; 'guys!': 0.09; 'pretend': 0.09; 'argument,': 0.16; 'formatted': 0.16; 'itself,': 0.16; 'operation.': 0.16; 'operator.': 0.16; 'received:65.55.116.7': 0.16; 'specifier': 0.16; 'str.format()': 0.16; 'tuple': 0.16; 'tuple.': 0.16; 'hack': 0.22; 'to:name:python-list@python.org': 0.22; 'print': 0.22; 'received:65.55.116': 0.24; 'skip:% 10': 0.24; 'header:In-Reply-To:1': 0.27; 'skip:- 40': 0.29; '[1]': 0.29; 'tuples': 0.31; 'another': 0.32; 'url:python': 0.33; 'problem': 0.35; 'thanks': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.37; 'represent': 0.38; 'url:library': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'making': 0.63; 'love': 0.65; 'email name:python-list': 0.65; 'design.': 0.68; 'honest': 0.78; 'hate': 0.91
X-TMN [O+TH/YwEEcCds12qhwCqxo6X5jPxZc48]
X-Originating-Email [carlosnepomuceno@outlook.com]
From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: PEP 378: Format Specifier for Thousands Separator
Date Fri, 24 May 2013 01:20:26 +0300
Importance Normal
In-Reply-To <knltkb$6b1$1@ger.gmane.org>
References <knltkb$6b1$1@ger.gmane.org>
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginalArrivalTime 23 May 2013 22:20:26.0662 (UTC) FILETIME=[B9DB3460:01CE5803]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2039.1369347695.3114.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369347695 news.xs4all.nl 15905 [2001:888:2000:d::a6]:41050
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45848

Show key headers only | View raw


----------------------------------------
> To: python-list@python.org
> From: tjreedy@udel.edu
[...]
>> 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.
>
> The problem is that interpolating 1 to many items into a string is *not*
> a binary operation. The needed hack to pretend that it is, using a tuple
> to represent multiple items rather than just itself, was one of the
> reasons for making string formatting a honest function, where multiple
> items to be formatted are passed as multiple arguments.

Thanks so much guys! Now I understand why some people hate %-formatting!

I don't think that's a problem because there's no format specifier for tuples in the %-formatting definition[1].
So it's up to the user to make the necessary conversion.

I still love the %-formatting style!

Can str.format() do the following?

f = '%d %d %d'
v = '1,2,3'
print f % eval(v)

If yes, how?


[1] http://docs.python.org/2/library/stdtypes.html#string-formatting 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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