Suggested coding style

Ian Kelly ian.g.kelly at gmail.com
Fri Sep 30 01:06:27 EDT 2011


On Thu, Sep 29, 2011 at 4:56 PM, rantingrick <rantingrick at gmail.com> wrote:
>> Agree that zfill seems to be redundant with str.format, although your
>> suggested syntax is atrocious, especially since a syntax already
>> exists that fits better in the already-complicated format specifier
>> syntax.
>
> It's interesting that you find the format specifier "complicated". I
> will admit that upon first glance i lamented the new format method
> spec and attempted to cling to the old string interpolation crap.
> However, as you use the new format method you will come to appreciate
> it. It's an adult beverage with an acquired taste. ;-)

I find it interesting that a self-proclaimed API expert like yourself
suggests that it isn't complicated.  The documentation on the format
specifiers is around 6 1/2 printed pages long, and that's not even
including the docs for the string.Formatter API.  Devin is right,
though, in that a better word for it would be "dense".

"Complicated" is not a bad thing here, because with that complexity
comes expressiveness.  It just means that care needs to be taken when
adding new options to ensure that they integrate well with the
existing syntax.

> One thing that may help format noobs is to look at the spec as two
> parts; the part before the colon and the part after the colon. If you
> break it down in this manner the meaning starts to shine through. I
> will agree, it is a lot of cryptic info squeezed into a small space
> HOWEVER you would no want a verbose format specification.

What makes you think I'm a "format noob"?  The details may have
evolved over the years, but the format specifiers are fundamentally
still the same old printf syntax that we've all been using for
decades.



More information about the Python-list mailing list