[Python-3000] More PEP 3101 changes incoming

Ron Adam rrr at ronadam.com
Thu Aug 16 21:35:33 CEST 2007



Paul Moore wrote:
> On 16/08/07, Ron Adam <rrr at ronadam.com> wrote:
>> Currently these particular examples aren't the syntax supported by the PEP.
>>  It's an alternative/possibly syntax only if there is enough support for a
>> serial left to right specification pattern as outlined.
> 
> Ah, I hadn't realised that. I've been skipping most of the
> discussions, mainly because of the lack of concrete examples :-)

And the discussion has progressed and changed in ways that makes thing a 
bit more confusing as well.  So the earlier parts of it don't connect with 
the later parts well.

It looks like the consensus is to keep something very close to the current 
%xxx style syntax just without the '%' on the front after all.  So this is 
all academic, although it may be useful sometime in th future.


>> I think most of developers here are still looking at various details and
>> are still undecided.  Do you have a preference for one or the other yet?
> 
> As evidenced by the fact that I failed to notice the difference, I
> can't distinguish the two :-)
> 
> All of the examples I've seen are hard to read. As Greg said, I find
> that I have to study the format string, mentally breaking it into
> parts, before I understand it. This is in complete contrast to
> printf-style "%.10s" formats. I'm not at all sure this is anything
> more than unfamiliarity, compounded by the fact that most of the
> examples I see on the list are relatively complex, or edge cases. But
> it's a major barrier to both understanding and acceptance of the new
> proposals.

Yes, familiarity is a big part.  I think the last version was the simplest 
because it breaks thing up logically to start with, (you don't have to do 
it mentally), it's just a matter of reading it left to right once you are 
familiar with the basic idea.

But it's still quite a bit different from what others are used to.  Enough 
so that it may take a bit of unlearning when things are changed this much. 
And enough so that it may seem overly complex at first glance.  In most 
cases it wouldn't be.

Anyways...  Skip to the new threads where they are discussing what the 
current status and things left to do are. Even with the older syntax, it 
will still be better than what we had because you can still create objects 
with custom formatting if you want to.  Most people won't even need that I 
suspect.

Cheers,
    Ron



> I'd still really like to see:
> 
> 1. A simple listing of common cases, maybe taken from something like
> stdlib uses of %-formats. Yes, most of them would be pretty trivial.
> That's the point!
> 2. A *very short* comparison of a few more advanced cases - I'd
> suggest formatting floats as fixed width, 2 decimal places (%5.2f),
> formatting 8-digit hex (%.8X) and maybe a simple date format
> (%Y-%m-%d). Yes, those are the sort of things I consider advanced.
> Examples I've seen in the discussion aren't "advanced" in my book,
> they are "I'll never use that" :-)
> 
> 3. Another very short list of a couple of things you can do with the
> new format, which you can't do with the existing % formats.
> Concentrate here on real-world use cases - tabular reports, reordering
> fields for internationalisation, things like that. As a data point,
> I've never needed to centre a field in a print statement. Heck, I
> don't even recall ever needing to specify how the sign of a number was
> printed!
> 
> I get the impression that the "clever" new features aren't actually
> going to address the sorts of formatting problems I hit a lot. That's
> fine, I can write code to do what I want, but there's a sense of YAGNI
> about the discussion, because (for example) by the time I need to
> format a centred, max-18, min-5 character number with 3 decimal places
> and the sign hard to the left, I'm also going to want to dot-fill a
> string to 30 characters and insert commas into the number, and I'm
> writing code anyway, so why bother with an obscure format string that
> only does half the job? (It goes without saying that if the format
> string can do everything I want, that argument doesn't work, but then
> we get to the complexity issues that hit regular expressions :-))
> 
> Sorry if this sounds a bit skeptical, but there's a *lot* of
> discussion here over a feature I expect to use pretty infrequently.
> 99% of my % formats use nothing more than %s!
> 
> Paul.
> 
> 


More information about the Python-3000 mailing list