str vs dict API size (was 'Re: left padding zeroes on a string...')

George Sakkis gsakkis at rutgers.edu
Fri Mar 25 18:06:11 EST 2005


"M.E.Farmer" <mefjr75 at hotmail.com> wrote:
>
> [snipped]
>
> Be sure to study up on string methods, it will save you time and
> sanity.
> Py> dir('')
> ['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
> '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__',
> '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__',
> '__mul__', '__ne__', '__new__', '__reduce__', '__repr__', '__rmul__',
> '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode',
> 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum',
> 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper',
> 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex',
> 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip',
> 'swapcase', 'title', 'translate', 'upper', 'zfill']

I'm getting off-topic here, but it strikes me that strings have so many methods (some of which are
of arguable utility, e.g. swapcase), while proposing two useful methods (http://tinyurl.com/5nv66)
for dicts -- a builtin with a considerably smaller API than str -- meets so much resistance. Any
insight ?

George


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Oh divine art of subtlety and secrecy! Through you we learn to be
invisible, through you inaudible and hence we can hold the enemy's fate
in our hands."

Sun Tzu, 'The Art of War'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





More information about the Python-list mailing list