[Python-ideas] Deprecating rarely used str methods

Antoine Pitrou solipsis at pitrou.net
Fri Aug 9 21:51:17 CEST 2013


On Fri, 09 Aug 2013 21:43:37 +0200
Mathias Panzenböck <grosser.meister.morti at gmx.net>
wrote:
> On 08/09/2013 10:10 AM, Antoine Pitrou wrote:
> > Le Thu, 08 Aug 2013 21:32:16 +0300,
> > Serhiy Storchaka <storchaka at gmail.com> a
> > écrit :
> >
> >> 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)
> >
> > -1 for deprecating those 3, they are much more readable than the format
> > equivalent (seriously, those smiley-like format specs are horrible...).
> >
> 
> You can write ljust/rjust like this:
> ljust: s+" "*(width-len(s))
> rjust: " "*(width-len(s))+s
> 
> Is this more readable or less?

Rather less, IMHO.

Regards

Antoine.




More information about the Python-ideas mailing list