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

peter at schneider-kamp.de.bbs peter at schneider-kamp.de.bbs
Mon Jul 17 10:50:02 EDT 2000


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"
  or
  "GvR".ljust(6,"12") =?= "GvR12"
  or
  "GvR".ljust(6,"12") =?= "GvR1212"

  I would vote for the first, but I am not sure it is obvious.
  Also I don't see any danger in the version implemented now.
  If you supply a string of length != 1, you get a very
  nice (helpful) TypeError.

Two reasons why:
- you could use "" to switch off padding, "N/A    " to fill a
  line with "N/A    N/A    N/A    N/A    " or " ." if you
  don't like """
  1.2.7. On the verge of sending........
  1.2.8. Really about to send now......."""
- it would be more general. Python likes that.

If we can work out the semantics, I volunteer to implement it.

Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de



More information about the Python-list mailing list