Adding Unicode methods to string objects
Before starting to code away, I would like to know which of the new Unicode methods should also be available on string objects. Here are the currently available methods: Unicode objects string objects ------------------------------------ capitalize capitalize center count count encode endswith endswith expandtabs find find index index isdecimal isdigit islower isnumeric isspace istitle isupper join join ljust lower lower lstrip lstrip replace replace rfind rfind rindex rindex rjust rstrip rstrip split split splitlines startswith startswith strip strip swapcase swapcase title title translate translate (*) upper upper zfill (*) The two hvae slightly different implementations, e.g. deletions are handled differently. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
Unicode objects string objects expandtabs
yes. I'm pretty sure there's "expandtabs" code in the strop module. maybe barry missed it?
center ljust rjust
probably. the implementation is trivial, and ljust/rjust are somewhat useful, so you might as well add them all (just cut and paste from the unicode class). what about rguido and lguido, btw?
zfill
no. </F>
Fredrik Lundh wrote:
Unicode objects string objects expandtabs
yes.
I'm pretty sure there's "expandtabs" code in the strop module. maybe barry missed it?
center ljust rjust
probably.
the implementation is trivial, and ljust/rjust are somewhat useful, so you might as well add them all (just cut and paste from the unicode class).
what about rguido and lguido, btw?
Ooops, forgot those, thanks :-)
zfill
no.
Why not ? Since the string implementation had all of the above marked as TBD, I added all four. What about the other new methods (.isXXX() and .splitlines()) ? .isXXX() are mostly needed due to the extended character properties in Unicode. They would be new to the string object world. .splitlines() is Unicode aware and also treats CR/LF combinations across platforms: S.splitlines([maxsplit]]) -> list of strings Return a list of the lines in S, breaking at line boundaries. If maxsplit is given, at most maxsplit are done. Line breaks are not included in the resulting list. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
zfill
no.
Why not ?
Zfill is (or ought to be) deprecated. It stems from times before we had things like "%08d" % x and no longer serves a useful purpose. I doubt anyone would miss it. (Of course, now /F will claim that PIL will break in 27 places because of this. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)
Guido van Rossum wrote:
zfill
no.
Why not ?
Zfill is (or ought to be) deprecated. It stems from times before we had things like "%08d" % x and no longer serves a useful purpose. I doubt anyone would miss it.
(Of course, now /F will claim that PIL will break in 27 places because of this. :-)
Ok, I'll remove it from both implementations again... (there was some email overlap). -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
I've ported most of the Unicode methods to strings now. Here's the new table: Unicode objects string objects ------------------------------------------------------------ capitalize capitalize center center count count encode endswith endswith expandtabs expandtabs find find index index isdecimal isdigit isdigit islower islower isnumeric isspace isspace istitle istitle isupper isupper join join ljust ljust lower lower lstrip lstrip replace replace rfind rfind rindex rindex rjust rjust rstrip rstrip split split splitlines splitlines startswith startswith strip strip swapcase swapcase title title translate translate upper upper zfill zfill I don't think that .isdecimal() and .isnumeric() are needed for strings since most of the added mappings refer to Unicode char points. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
participants (3)
-
Fredrik Lundh -
Guido van Rossum -
M.-A. Lemburg