[Python-3000] More PEP 3101 changes incoming

Jim Jewett jimjjewett at gmail.com
Wed Aug 15 18:07:22 CEST 2007


On 8/14/07, Ron Adam <rrr at ronadam.com> wrote:
> Jim Jewett wrote:
> > On 8/13/07, Ron Adam <rrr at ronadam.com> wrote:

> >>        {name[:][type][alignment_term][,content_modifying_term]}

> > ...  You used the (alignment term)
> > width as the number of digits before the decimal,
> > instead of as the field width.

> You can leave out either term.  So that may have
> been what you are seeing.

I thought I was going based on your spec, rather than the examples.

>      {0:f8.2}

Because there is no comma, this should be a field of width 8 -- two
after a decimal point, the decimal point itself, and at most 5 digits
(or 4 and sign) before the the decimal point

I (mis?)read your messge as special-casing float to 8 digits before
the decimal point, for a total field width of 11.


...
> Minimal width with fill for shorter than width items.  It
> expands if the length of the item is longer than width.
 ...
> > Can I say "width=whatever it takes, up to 72 chars ...
> > but don't pad it if you don't need to"?

> That's the default behavior.

If width is only a minimum, where did it get the maximum of 72 chars part?

> > I'm not sure that variable lengths and alignment even
> > *should* be supported in the same expression, but if
> > forcing everything to fixed-width would be enough of
> > a change that it needs an explicit callout.

> Alignment is needed for when the length of the value is shorter than the
> length of the field.  So if a field has a minimal width, and a value is
> shorter than that, it will be used.

I should have been more explicit -- variable length *field*.  How can
one report say "use up to ten characters if you need them, but only
use three if that is all you need" and another report say "use exactly
ten characters; right align and fill with spaces."

-jJ


More information about the Python-3000 mailing list