Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33779
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; '%s"': 0.07; 'formatting': 0.07; 'method,': 0.07; 'referring': 0.07; 'strings.': 0.07; 'python': 0.09; '(1,': 0.09; '22,': 0.09; 'compact': 0.09; 'other)': 0.09; 'parsed': 0.09; 'pep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'underlying': 0.09; 'looked': 0.10; "skip:' 30": 0.15; '"%"': 0.16; '"%s': 0.16; "(i'm": 0.16; 'advantage.': 0.16; 'blessing': 0.16; 'handling.': 0.16; 'notice;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'relevance': 0.16; 'sees': 0.16; 'syntax.': 0.16; '{}"': 0.16; 'string': 0.17; 'wrote:': 0.17; '"you': 0.17; 'exists': 0.17; 'skip:{ 20': 0.17; 'thu,': 0.17; 'unicode': 0.17; '>>>': 0.18; 'skip:" 40': 0.20; 'skip:% 10': 0.22; "python's": 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'handling': 0.27; 'in.': 0.27; 'header:X-Complaints-To:1': 0.28; 'rest': 0.28; 'this?': 0.28; 'chris': 0.28; '120': 0.29; '>>>>': 0.29; 'finds': 0.29; 'lies': 0.29; 'piece': 0.29; 'strings,': 0.29; "i'm": 0.29; 'maybe': 0.29; 'function': 0.30; 'on,': 0.30; 'code': 0.31; 'from:addr:yahoo.co.uk': 0.32; 'asked': 0.33; 'like:': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; 'version': 0.34; 'nov': 0.35; 'said,': 0.35; 'pm,': 0.35; 'something': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'skip:{ 10': 0.36; 'should': 0.36; 'two': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'things': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'easy': 0.60; 'world': 0.63; 'more': 0.63; 'decided': 0.65; 'hang': 0.65; 'ago.': 0.66; 'absolutely': 0.84; '4:00': 0.84; 'expressive': 0.84; 'glad': 0.86; "'you": 0.91; 'obvious,': 0.91; 'hand,': 0.97 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Yet another Python textbook |
| Date | Wed, 21 Nov 2012 23:32:34 +0000 |
| References | <CAB89DN0nusHZU32zP5UbTSUH8P7aXJomssBT-Jge7LEhaOtphg@mail.gmail.com> <CALwzid=3b_Gv3XR5iYvo7Pc0ZjXERB60daT9AjVoOG1OAP9vNg@mail.gmail.com> <CAB89DN0M5NzpoLRtcXRtM4Vs4xrOfw0wZq64GkU-DKy=Ei8HJQ@mail.gmail.com> <mailman.34.1353398989.29569.python-list@python.org> <31a82817-8c9b-4dd2-a468-89d8d081fd1b@googlegroups.com> <mailman.96.1353445247.29569.python-list@python.org> <50AD0962.5080002@ncf.ca> <CAPTjJmr55ZjpF9RBog39QZyTRixh=tTJH-5_pu3YTL4hWmfCAg@mail.gmail.com> <CAN1F8qXksLhbwb-DsvpcMdQDTkwWp1u92F7yObS7=TncvT9xwQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-92-24-212-75.ppp.as43234.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
| In-Reply-To | <CAN1F8qXksLhbwb-DsvpcMdQDTkwWp1u92F7yObS7=TncvT9xwQ@mail.gmail.com> |
| X-Antivirus | avast! (VPS 121121-0, 21/11/2012), Outbound message |
| X-Antivirus-Status | Clean |
| 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.184.1353540673.29569.python-list@python.org> (permalink) |
| Lines | 97 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353540673 news.xs4all.nl 6894 [2001:888:2000:d::a6]:40083 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33779 |
Show key headers only | View raw
On 21/11/2012 23:21, Joshua Landau wrote:
> On 21 November 2012 22:17, Chris Angelico <rosuav@gmail.com> wrote:
>
>> On Thu, Nov 22, 2012 at 4:03 AM, Colin J. Williams <cjw@ncf.ca> wrote:
>>> On 20/11/2012 4:00 PM, Chris Angelico wrote:
>>>> To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393
>>>> strings. Take no notice; the rest of the world sees this as a huge
>>>> advantage. Python is now in a VERY small group of languages (I'm aware
>>>> of just one other) that have absolutely proper Unicode handling *and*
>>>> efficient string handling.
>>>>
>>>> ChrisA
>>>>
>>> It's interesting to see that someone else finds the format function to
>> be a
>>> pain. Perhaps the problem lies with the documentation.
>>
>> Hang on, what? I'm not sure where the format function comes in. I was
>> referring to the underlying representation.
>>
>> That said, though, I'm just glad that %-formatting is staying. It's an
>> extremely expressive string formatting method, and exists in many
>> languages (thanks to C's heritage). Pike's version is insanely
>> powerful, Python's is more like C's, but all three are compact and
>> convenient.
>>
>> str.format(), on the other hand, is flexible. It strikes me as rather
>> more complicated than a string formatting function needs to be, but
>> that may be a cost of its flexibility.
>>
>
> Since we've decided to derail the conversation...
>
> "{}".format() is a blessing an "" % () should go. "%" has no relevance to
> strings, is hard to "get" and has an appalling* syntax. Having two syntaxes
> just makes things less obvious, and the right choice rarer.
>
> str.format is also really easy. I don't understand what makes you disagree.
>
> Easy vs easier:
>
>>>> "%s %s %s" % (1, 2, 3)
> '1 2 3'
>
>>>> "{} {} {}".format(1, 2, 3)
> '1 2 3'
>
> Easy vs easier:
>
>>>> "You have %(spam)s spam and %(eggs)s eggs!" % {"spam": 43, "eggs": 120}
> 'You have 43 spam and 120 eggs!'
>
>>>> "You have {spam} spam and {eggs} eggs!".format(spam=43, eggs=120)
> <OR>
>>>> "You have {spam} spam and {eggs} eggs!".format(**{"spam": 43, "eggs":
> 120})
> 'You have 43 spam and 120 eggs!'
>
> Eh...? vs easy:
>
>>>> "Thing %s has state %+o!" % ("#432", 14)
> 'Thing #432 has state +16!
>
>>>> "Thing {} has state {:+o}!".format("#432", 14)
> 'Thing #432 has state +16!'
>
> *Additionally*, a = str.format is much *better* than a = str.__mod__.
>
> I have a piece of code like this:
> "{fuscia}{{category__name}}/{reset}{{name}} {green}{{version}}{reset}:\n
> {{description}}"
>
> Which *would* have looked like this:
> "%(fuscia)s%%(category__name)s/%(reset)s%%(name)s
> %(green)s%%(version)s%(reset)s:\n %%(description)s"
>
> Which would have parsed to something like:
> 'FUSCIA{category__name}/RESET{name} GREEN{version}RESET:\n {description}'
> and
> 'FUSCIA%(category__name)s/RESET%(name)s GREEN%(version)sRESET:\n
> %(description)s'
>
> Can you seriously say you don't mind the "%(name)s"s in this?
>
> * "A {} is in the {}" vs "A %s is in the %s"?
>
>
>
C %f style formatting is never going to go so live with it. I know as I
asked maybe two years ago. On Python-dev. I think.
--
Cheers.
Mark Lawrence.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Yet another Python textbook Chris Angelico <rosuav@gmail.com> - 2012-11-20 19:09 +1100
Re: Yet another Python textbook wxjmfauth@gmail.com - 2012-11-20 06:57 -0800
Re: Yet another Python textbook Chris Angelico <rosuav@gmail.com> - 2012-11-21 08:00 +1100
Re: Yet another Python textbook wxjmfauth@gmail.com - 2012-11-21 06:49 -0800
Re: Yet another Python textbook wxjmfauth@gmail.com - 2012-11-21 06:49 -0800
Re: Yet another Python textbook "Colin J. Williams" <cjw@ncf.ca> - 2012-11-21 12:03 -0500
Re: Yet another Python textbook Chris Angelico <rosuav@gmail.com> - 2012-11-22 09:17 +1100
Re: Yet another Python textbook "Colin J. Williams" <cjw@ncf.ca> - 2012-11-22 07:24 -0500
Re: Yet another Python textbook Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-22 11:27 -0700
Re: Yet another Python textbook "Colin J. Williams" <cjw@ncf.ca> - 2012-11-22 17:41 -0500
Re: Yet another Python textbook Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-23 03:26 +0000
Re: Yet another Python textbook Terry Reedy <tjreedy@udel.edu> - 2012-11-22 17:12 -0500
Re: Yet another Python textbook Dave Angel <d@davea.name> - 2012-11-21 17:58 -0500
Re: Yet another Python textbook Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-21 16:11 -0700
Re: Yet another Python textbook Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 23:26 +0000
Re: Yet another Python textbook Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-21 23:32 +0000
Re: Yet another Python textbook Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-21 17:19 -0700
Re: Yet another Python textbook Terry Reedy <tjreedy@udel.edu> - 2012-11-21 23:04 -0500
Re: Yet another Python textbook Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-20 21:55 +0000
Re: Yet another Python textbook Chris Angelico <rosuav@gmail.com> - 2012-11-21 09:25 +1100
csiph-web