string methods (was Re: [Python-Dev] A house upon the sand)

M.-A. Lemburg mal@lemburg.com
Mon, 27 Nov 2000 10:32:46 +0100


Fredrik Lundh wrote:
> 
> Charles wrote:
> > On the other hand it is not clear to me why "capwords" and "zfill" did
> > not become methods of string objects.
> 
> fwiw, they were both present in my original unicode
> implementation:
> 
> >>> from unicode import unicode
> >>> a = unicode("hello world")
> >>> a.capwords()
> 'Hello World'
> >>> a.zfill(20)
> '000000000hello world'

.zfill() is implemented for both strings and Unicode, .capwords()
only for Unicode. Both are disabled, though. I talked with
Guido about these methods and we decided to leave those two
methods disabled in the implementation. They just don't provide
much extra generally useful functionality.

s.capwords() can be emulated with ' '.join(s.capitalize().split()),
BTW.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/