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


Groups > comp.lang.python > #33094

Re: Format specification mini-language for list joining

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <kwpolska@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'syntax': 0.03; 'subject:skip:s 10': 0.05; 'python': 0.09; 'etc.),': 0.09; 'subject:language': 0.09; 'sat,': 0.15; "'hello": 0.16; 'cryptic.': 0.16; 'gpg': 0.16; 'imo,': 0.16; 'subject:joining': 0.16; 'syntax,': 0.16; 'useless.': 0.16; 'worse.': 0.16; 'wrote:': 0.17; 'exists': 0.17; 'skip:{ 20': 0.17; 'meant': 0.21; "python's": 0.23; 'idea': 0.24; 'second': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.25; '---': 0.26; 'converting': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'consult': 0.29; "skip:' 10": 0.30; 'docs': 0.33; 'to:addr:python-list': 0.33; 'changed': 0.34; 'received:google.com': 0.34; 'nov': 0.35; 'said,': 0.35; 'community': 0.35; 'so,': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'first': 0.61; 'more': 0.63; 'opt': 0.78; 'it\xe2\x80\x99s': 0.84; 'you\xe2\x80\x99re': 0.91; 'hate': 0.93; 'proposition': 0.93; 'url:tk': 0.93; 'old.': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=fJalT35jhXu4IUe3nM22tKHP94nI9KVkfF9Frb1C4yI=; b=kk2vUXYOWGiAfd4JZsndlLKGUb6sxP2JFqShW+VOH6BfHXctsk/4PSnJIpX7z0Tn88 JdNLpybTgjjIvSgTNVfbk5aUFBSzfzSGjbedoVCQcpDPJQ4Pt/T1usCL77kEeCNkT8Ak j4PD+H/PwSAAYop+viPlOA5MsofrECv0/eW9hJSJ0FTSBAUoRVk6ShxdJnB+cAVc1HpL n3NERQlj1P5c1HZgRCfYYdEAaGW/GUkW8qgm4gJBC9QdpGHFoaOTXH6yyhSoB90IR5UH xyIZyufgECCYy1eWmUKkDoO10ZjZ4SS31lqpVTNANiNPLH6pyvdI7U89gn1eB50PyP3M GSPg==
MIME-Version 1.0
In-Reply-To <7xwqxt765m.fsf@ruckus.brouhaha.com>
References <92ada057-5a72-4186-bd22-4ccb600b8e45@googlegroups.com> <7xwqxt765m.fsf@ruckus.brouhaha.com>
Date Sat, 10 Nov 2012 18:13:47 +0100
Subject Re: Format specification mini-language for list joining
From Kwpolska <kwpolska@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.3537.1352567636.27098.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352567636 news.xs4all.nl 6987 [2001:888:2000:d::a6]:38208
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33094

Show key headers only | View raw


On Sat, Nov 10, 2012 at 5:51 PM, Paul Rubin <no.email@nospam.invalid> wrote:
> […] Python's format strings are pretty much the same as C's format strings […]

You’re thinking about the old % syntax, 'Hello %s!' % 'world'.  The OP
meant the new str.format syntax ('Hello {}!'.format('world')).
---

IMO, the idea is useless.  First of, format() exists since 2.6, which
was released in 2008.  So, it would be hard to use it anyways.  Second
of, which is more readable:

    out = 'Temperatures: {0:", ":.1f} Celsius'.format(temps)

or

    out = 'Temperatures: {} Celsius'.format(', '.join(temps))

101% of the Python community would opt for the second format.  Because
your format is cryptic.  The current thing is already
not-quite-easy-to-understand when you use magic (aligning, type
converting etc.), but your proposition is much worse.  And I hate to
consult the docs while working on something.  As I said, it’s hard to
even get this one changed because str.format is 4 years old.

-- 
Kwpolska <http://kwpolska.tk>
stop html mail      | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16

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


Thread

Format specification mini-language for list joining Tobia Conforto <tobia.conforto@gmail.com> - 2012-11-10 02:26 -0800
  Re: Format specification mini-language for list joining Paul Rubin <no.email@nospam.invalid> - 2012-11-10 08:51 -0800
    Re: Format specification mini-language for list joining Kwpolska <kwpolska@gmail.com> - 2012-11-10 18:13 +0100
      Re: Format specification mini-language for list joining Tobia Conforto <tobia.conforto@gmail.com> - 2012-11-10 13:11 -0800
      Re: Format specification mini-language for list joining Tobia Conforto <tobia.conforto@gmail.com> - 2012-11-10 13:11 -0800
  Re: Format specification mini-language for list joining Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-10 16:55 +0000

csiph-web