[Patch] {l,r}just with optional pad character parameter

tjreedy at udel.edu.bbs tjreedy at udel.edu.bbs
Mon Jul 17 12:50:01 EDT 2000


"Peter Schneider-Kamp" <peter at schneider-kamp.de> wrote in message
news:39733AC7.96CCBF81 at schneider-kamp.de...
> Thomas Wouters wrote:
> >
> > As for the patch itself, it looks okay, though I'd say the restriction
on
> > padchar being a single character is a bit strange. Why not allow
multiple
> > characters as padding ? string.join() allows strings instead of single
> > characters, too.
>
> Two reasons why not:
> - it would have been harder to implement <wink>
> - undetermined semantics:
>   "GvR".ljust(6,"12") =?= "GvR121"

This is exactly what I would expect -- a 6 char result string

>   or
>   "GvR".ljust(6,"12") =?= "GvR12"
>   or
>   "GvR".ljust(6,"12") =?= "GvR1212"

But these are not the right length -- someone who wanted something like
this
should examine lengths of input and pad and adjust whatever accordingly.

>   I would vote for the first, but I am not sure it is obvious.

Anything else would surprise me, so I agree.  TJR



More information about the Python-list mailing list