Negative indices in UserString.MutableString
Currently UserString.MutableString does not support negative indices:
import UserString UserString.MutableString("foo")[-1] = "bar" Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/Python-test/dist/src/Lib/UserString.py", line 149, in __setitem__ if index < 0 or index >= len(self.data): raise IndexError IndexError
Should this be fixed so that negative value are treated as being relative to the end? Bye, Walter Dörwald
On Thu, Feb 17, 2005, Walter D?rwald wrote:
Currently UserString.MutableString does not support negative indices:
import UserString UserString.MutableString("foo")[-1] = "bar" Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/Python-test/dist/src/Lib/UserString.py", line 149, in __setitem__ if index < 0 or index >= len(self.data): raise IndexError IndexError
Should this be fixed so that negative value are treated as being relative to the end?
Yup! As usual, patches welcome. (Yes, I'm comfortable channeling Guido here.) -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death." --GvR
participants (2)
-
Aahz -
Walter Dörwald