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

References <92ada057-5a72-4186-bd22-4ccb600b8e45@googlegroups.com> <7xwqxt765m.fsf@ruckus.brouhaha.com>
Date 2012-11-10 18:13 +0100
Subject Re: Format specification mini-language for list joining
From Kwpolska <kwpolska@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3537.1352567636.27098.python-list@python.org> (permalink)

Show all headers | 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