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


Groups > comp.lang.python > #45689

RE: PEP 378: Format Specifier for Thousands Separator

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!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; 'cpython': 0.05; 'subject:PEP': 0.07; '-0500': 0.09; 'attributes': 0.09; 'ex:': 0.09; 'formatting': 0.09; 'raises': 0.09; 'release,': 0.09; 'try:': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'def': 0.12; 'windows': 0.15; '#this': 0.16; "','": 0.16; 'behaviour.': 0.16; 'caveats': 0.16; 'closed.': 0.16; 'deprecated,': 0.16; 'illustrate': 0.16; 'typeerror:': 0.16; 'unlikely': 0.16; 'valueerror,': 0.16; 'index': 0.16; 'trying': 0.19; 'received:65.55.116': 0.24; 'mention': 0.26; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:- 40': 0.29; 'character': 0.29; 'url:mailman': 0.30; 'code': 0.31; "skip:' 10": 0.31; '3.x': 0.31; 'url:python': 0.33; 'date:': 0.34; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'url:listinfo': 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'email addr:python.org': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'does': 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'url:mail': 0.40; 'new': 0.61; 'email addr:gmail.com': 0.63; 'email name:python-list': 0.65; 'here': 0.66; 'soon.': 0.71; '9.1': 0.84; 'freebsd': 0.84; '2013': 0.98
X-TMN [PGlF1sFWAZNgwuV1DE8cl5HRTILOWyWR]
X-Originating-Email [carlosnepomuceno@outlook.com]
From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
To comp.lang.python <python-list@python.org>
Subject RE: PEP 378: Format Specifier for Thousands Separator
Date Tue, 21 May 2013 23:22:24 +0300
Importance Normal
In-Reply-To <519BD0D2.5080203@gmail.com>
References <519BD0D2.5080203@gmail.com>
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginalArrivalTime 21 May 2013 20:22:24.0143 (UTC) FILETIME=[E78511F0:01CE5660]
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.1939.1369167746.3114.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369167746 news.xs4all.nl 15909 [2001:888:2000:d::a6]:37732
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45689

Show key headers only | View raw


----------------------------------------
> Date: Tue, 21 May 2013 14:53:54 -0500
> From: bahamutzero8825@gmail.com
> To: python-list@python.org
[...]
>>
> What myth? People should indeed be using .format(), but no one said % formatting was going away soon. Also, the suggested change to the docs
> wasn't made and the issue is closed. The current docs do not say that % formatting isn't going to be deprecated, but it does mention its
> caveats and suggests .format(). If you are trying to say that % formatting will never ever go away, then you are wrong. It is highly
> unlikely to go away in a 3.x release, but /may/ get phased out in Python 4.0.

I vote for keeping str.__mod__()!

Anyway, is it possible to overload str.__mod__() without deriving a class? I mean to have something like:

old_mod = str.__mod__
def new_mod(x):
    global old_mod
    try:
        old_mod(x)
    except ValueError, ex:
        #catch ValueError: unsupported format character ',' (0x2c) at index 1
        #process new '%,d' format here
        return '{:,}'.format(x)  #just to illustrate the behaviour. it would have it's own faster code

str.__mod__ = new_mod  #this raises TypeError: can't set attributes of built-in/extension type 'str'
sys.stdout.write('num=%,d\n' % 1234567)


> --
> CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1
> --
> http://mail.python.org/mailman/listinfo/python-list 		 	   		  

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


Thread

RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-21 23:22 +0300
  Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 02:42 +0000
    RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 05:56 +0300
      Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 03:08 +0000
        RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 06:38 +0300
          Re: PEP 378: Format Specifier for Thousands Separator 88888 Dihedral <dihedral88888@gmail.com> - 2013-05-22 00:14 -0700
        Re: PEP 378: Format Specifier for Thousands Separator Ned Batchelder <ned@nedbatchelder.com> - 2013-05-22 07:25 -0400
        RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 14:52 +0300

csiph-web