[Python-Dev] UserString

Raymond Hettinger raymond.hettinger at verizon.net
Sun Feb 20 05:20:25 CET 2005


I noticed that UserString objects have methods that do not accept other
UserString objects as arguments:


>>> from UserString import UserString
>>> UserString('slartibartfast').count(UserString('a'))

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in -toplevel-
    UserString('slartibartfast').count(UserString('a'))
  File "C:\PY24\lib\UserString.py", line 66, in count
    return self.data.count(sub, start, end)
TypeError: expected a character buffer object

>>> UserString('abc') in UserString('abcde')

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in -toplevel-
    UserString('abc') in UserString('abcde')
  File "C:\PY24\lib\UserString.py", line 35, in __contains__
    return char in self.data
TypeError: 'in <string>' requires string as left operand


This sort of thing is easy to test for and easy to fix.  The question is
whether we care about updating this module anymore or is it a relic.
Also, is the use case one that we care about.  AFAICT, this has never
come up before.


Raymond



More information about the Python-Dev mailing list