PEP proposal: enhanced string functions
kwg at renre-europe.com
Wed Nov 14 15:37:35 CET 2001
On Wed, 2001-11-14 at 13:46, Mikael Olofsson wrote:
> On 14-Nov-2001 Matthew Dixon Cowles wrote:
> > I'd prefer to be able to pass a sequence to strip() and have
> > any of those characters stripped.
> On 14-Nov-2001 Oliver Fromme wrote:
> > For the center() case, it might be useful to optionally
> > allow another argument, so you can have different padding
> > on the left and on the right.
> > Example:
> > >>> string.center(" Title ", 25, ">", "<")
> > '>>>>>>>>> Title <<<<<<<<<'
> To conform with Matthew's proposal about strip(), you might want to use
> the same argument for left and right padding in center(), as in
> >>> string.center(" Title ", 25, "><")
> '>>>>>>>>> Title <<<<<<<<<'
Mikael, I think you're wrong to think that center should only take only
What if somebody wants the result to look like "-=-=-=-= Title ......."?
That said, how about having it that:
1. When there are 3 parameters, the third parameter is used for
padding on both the left and right of " Title"
>>> string.center(" Title ", , "-=")
'-=-=-=-=- Title -=-=-=-=-'
2. When there are 4 parameters, the third parameter is used
for padding on the left of " Title " and the fourth parameter is
used for padding on the right.
>>> string.center(" Title ", , "-=", "#")
'-=-=-=-=- Title #########'
More information about the Python-list