From: MRAB on
Mark Summerfield wrote:
> On 2 Dec, 19:28, David H Wild <dhw...(a)talktalk.net> wrote:
>> In article
>> <351fcb4c-4e88-41b0-a0aa-b3d63832d...(a)e23g2000yqd.googlegroups.com>,
>> Mark Summerfield <l...(a)qtrac.plus.com> wrote:
>>
>>> I only just found out that I was supposed to give a different URL:
>>> http://www.informit.com/promotions/promotion.aspx?promo=137519
>>> This leads to a web page where you can download the document (just by
>>> clicking the "Download Now" button), but if you _choose_ you can also
>>> enter your name and email to win some sort of prize.
>> There is a typographical fault on page 4 of this pdf file. The letter "P"
>> is missing from the word "Python" at the head of the comparison columns.
>
Which is page 4? The page numbers are missing! (But the column titles
look OK.) :-)

> I can't see that problem---I've tried the PDF with evince, gv,
> acroread, and okular, and no missing "P" on page 4. I don't have a
> machine with RISC OS on it so I can't test on that environment!
>
From: John Posner on
On Wed, 02 Dec 2009 13:34:11 -0500, Carsten Haese
<carsten.haese(a)gmail.com> wrote:

>
> With string interpolation, you don't need to do that, either.
>>>> '%*d' % (8,456)
> ' 456'
>

Thanks, Carsten and Mark D. -- I'd forgotten about the use of "*" in
minimum-field-width specs and precision specs (doh). How about this:

"pi={1:.{0}f} e={2:.{0}f}".format(5, math.pi, math.e)

(result: 'pi=3.14159 e=2.71828')

Can the Python2 %-formating facility handle this without repeating the "5"
argument?

Even if it can, I stand by my original suggestion: include an example to
show that the arguments to str.format() can be used on both the left and
the right of a ":" in a replacement field.

-John
From: Terry Reedy on
Mark Summerfield wrote:

> Well it seems clear to me that the BDFL wants to kill of % formatting,
> but wasn't able to for Python 3...

Definitely. I thought of adding autonumbering of fields (in 3.1) in
response to his inquiry about the barriers to moving to .format. That
solved 'simplicity of defaults'. The other, 'Autoconversion of installed
base' still awaits.

> So I still think it is reasonable
> (1) to describe it as deprecated and (2) to only teach and use
> str.format().

At the moment (3.1) there are, unfortunately, library packages that
require % for formatting (logging, I believe, for one). There has been
discussion on adding a new option for 3.2, but I do not know what will
happen. Depends on whether you want to be absolutely complete. I
strictly use .format when I can, which so far is always.

Terry Jan Reedy

From: Antoine Pitrou on

Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit :
> I've produced a 4 page document that provides a very concise summary of
> Python 2<->3 differences plus the most commonly used new Python 3
> features. It is aimed at existing Python 2 programmers who want to start
> writing Python 3 programs and want to use Python 3 idioms rather than
> those from Python 2 where the idioms differ.
[...]
>
> It is available as a free PDF download (no registration or anything)
> from InformIT's website. Here's the direct link:

This is great!

Just one thing:

« Copyright © Qtrac Ltd. 2009. All rights reserved »

Might I suggest that you release it under a free license instead?
(such as the CC by, CC by-sa, or the Free Art License)

Regards

Antoine.

From: Mark Summerfield on
On 2 Dec, 22:49, "John Posner" <jjpos...(a)optimum.net> wrote:
> On Wed, 02 Dec 2009 13:34:11 -0500, Carsten Haese  
>
> <carsten.ha...(a)gmail.com> wrote:
>
> > With string interpolation, you don't need to do that, either.
> >>>> '%*d' % (8,456)
> > '     456'
>
> Thanks, Carsten and Mark D. -- I'd forgotten about the use of "*" in  
> minimum-field-width specs and precision specs (doh). How about this:
>
>    "pi={1:.{0}f} e={2:.{0}f}".format(5, math.pi, math.e)
>
>    (result: 'pi=3.14159 e=2.71828')
>
> Can the Python2 %-formating facility handle this without repeating the "5"  
> argument?
>
> Even if it can, I stand by my original suggestion: include an example to  
> show that the arguments to str.format() can be used on both the left and  
> the right of a ":" in a replacement field.
>
> -John

I can't squeeze another line into the last column of the last page (I
already tried).

However, a natural place to put this would be in the first section on
the first page. But I want _common_ not _clever_, i.e., an example
that shows a common use of * in % that I can then show using a nested
replacement field. The idea is that people can look at the left hand
column, recognize an idiom they use, and then be able to figure out
from the right hand column how to do the same in Python 3.

Anyway, I've come up with a tiny example and managed to squeeze it in,
so hopefully it'll appear on InformIT's web site in a day or so.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: can you say it please
Next: can python do this?