Author: raymond.hettinger Date: Wed Feb 6 21:59:41 2008 New Revision: 60628
Modified: python/branches/py3k/Lib/UserList.py python/branches/py3k/Lib/UserString.py Log: Let the world know that UserList is a MutableSequence. Modified: python/branches/py3k/Lib/UserList.py ============================================================================== --- python/branches/py3k/Lib/UserList.py (original) +++ python/branches/py3k/Lib/UserList.py Wed Feb 6 21:59:41 2008 @@ -1,6 +1,8 @@ """A more or less complete user-defined wrapper around list objects.""" -class UserList: +import collections + +class UserList(collections.MutableSequence): def __init__(self, initlist=None): self.data = [] if initlist is not None: @@ -69,3 +71,5 @@ self.data.extend(other.data) else: self.data.extend(other) + +collections.MutableSequence.register(UserList) Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Wed Feb 6 21:59:41 2008 @@ -6,10 +6,11 @@ This module requires Python 1.6 or later. """ import sys +import collections __all__ = ["UserString","MutableString"] -class UserString: +class UserString(collections.Sequence): def __init__(self, seq): if isinstance(seq, str): self.data = seq @@ -161,7 +162,9 @@ def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width)) -class MutableString(UserString): +collections.Sequence.register(UserString) + +class MutableString(UserString, collections.MutableSequence): """mutable string objects Python strings are immutable objects. This has the advantage, that @@ -230,6 +233,8 @@ self.data *= n return self +collections.MutableSequence.register(MutableString) + if __name__ == "__main__": # execute the regression test to stdout, if called as a script: import os _______________________________________________ Python-3000-checkins mailing list Python-3000-checkins@python.org http://mail.python.org/mailman/listinfo/python-3000-checkins