News123 wrote:
Thomas Jollans wrote:


string.rstrip( [ '-dir' ] )
or  as
string.rstrip( '-dir' )
The former should certainly raise an exception. '-dir' is not a single
character !
Or it should actually strip '-dir', or '-dir-dir', but not 'r--i'... but
that's just silly.

It's silly with the example of '-dir' it's much less silly with
a string like ' \t'.

The doc is rather clear about it:
str.rstrip([chars])

It is marked 'chars' and not 'suffix'

The textual description is even clearer:
"The chars argument is not a suffix; rather, all combinations of its
values are stripped:"


When  I asked in this grpup about a way of how to strip off a prefix I
never even considered strip as a solution having read the doc before.

I also think, that the functionality of strip / rstrip is useful as is.


It would just be great to have functions to strip  prefixes/suffixes.
If these new commands were alphabetically next to the classic  commands,
( e.g. strip_prefix / rstrip_suffix)  then almost everybody looking for
string functions would probably use the function, which is appropriate
for his purpose.

Breaking backwardscompatibility within python 3 might not be the best
choice.

[snip]
How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something
similar?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to