Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33798
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news0.firedrake.org!news.xcski.com!ncf.ca!not-for-mail |
|---|---|
| From | "Colin J. Williams" <cjw@ncf.ca> |
| Newsgroups | comp.lang.python |
| Subject | Re: Yet another Python textbook |
| Date | Thu, 22 Nov 2012 07:24:38 -0500 |
| Organization | National Capital Freenet, Ottawa, Ontario, Canada |
| Lines | 66 |
| Sender | fn681@dsl-153-214.b2b2c.ca |
| Message-ID | <50AE1986.2080605@ncf.ca> (permalink) |
| 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> <mailman.180.1353536254.29569.python-list@python.org> |
| NNTP-Posting-Host | dsl-153-214.b2b2c.ca |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | theodyn.ncf.ca 1353587080 3139 66.158.153.214 (22 Nov 2012 12:24:40 GMT) |
| X-Complaints-To | complaints@ncf.ca |
| NNTP-Posting-Date | 22 Nov 2012 12:24:40 GMT |
| Cc | rosuav@gmail.com |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
| In-Reply-To | <mailman.180.1353536254.29569.python-list@python.org> |
| Xref | csiph.com comp.lang.python:33798 |
Show key headers only | View raw
From Yet another Python textbook
On 21/11/2012 5:17 PM, Chris Angelico 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.
The OP wrote:
"The absurd flexible string representation has practically
borrowed the idea to propose once Python has a teaching tool."
I perhaps stretched this to refer specifically on one aspect, formatting
in my comment.
>
> 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.
>
> ChrisA
Yes is is complicated.
From my reading of the docs, it seems to me that the three following
should be equivalent:
(a) formattingStr.format(values)
with
(b) format(values, formattingStr)
or
(c) tupleOfValues.__format__(formattingStr
Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))
(-25.61, 95 ).__format__('{:-^14f}{:^14d}')
The second fails, perhaps because values can only be a single value.
The third fails, the reason is unclear.
Steven D'Aprano earlier said that a better diagnostic tool is planned
for Python 3.4.
Should we retreat to %-formatting for now?
Colin W.
>
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