[Python-ideas] Deprecating rarely used str methods
David Mertz
mertz at gnosis.cx
Thu Aug 8 21:48:21 CEST 2013
-1 on all the parts.
I've used Python long enough to remember being thankful that many of the
functions in the 'string' module were duplicated as str methods. It's
generally convenient to have them there.
I can't actually argue that I use str.swapcase() much (maybe ever), but all
the rest are handy and things I actually use. Yes, you can technically get
the results out of str.format(), but the format mini-language is rather
difficult and arcane and I can't really use it without the documentation
open in another window.
On Thu, Aug 8, 2013 at 11:32 AM, Serhiy Storchaka <storchaka at gmail.com>wrote:
> The str class have some very rarely used methods. When was the last time
> you used swapcase() (not counting the time of apprenticeship)? These
> methods take place in a source code, documentation and a memory of
> developers. Due to the large number of methods, some of the really
> necessary methods can be neglected. I propose to deprecate rarely used
> methods (especially that for most of them there is another, more obvious
> way) and remove them in 4.0.
>
> s.ljust(width) == '{:<{}}'.format(s, width) == '%-*s' % (width, s)
> s.ljust(width, fillchar) == '{:{}<{}}'.format(s, fillchar, width)
> s.rjust(width) == '{:>{}}'.format(s, width) == '%*s' % (width, s)
> s.rjust(width, fillchar) == '{:{}>{}}'.format(s, fillchar, width)
> s.center(width) == '{:^{}}'.format(s, width)
> s.center(width, fillchar) == '{:{}^{}}'.format(s, fillchar, width)
>
> str(n).zfill(width) == '{:0={}}'.format(n, width) == '%0*.f' % (width,n)
>
> str.swapcase() is just not needed.
>
> str.expandtabs([tabsize]) is rarely used and can be moved to the textwrap
> module.
>
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130808/7298a15a/attachment-0001.html>
More information about the Python-ideas
mailing list