Mutable Strings - Any libraries that offer this?
Mark Lawrence
breamoreboy at yahoo.co.uk
Sun Jul 26 07:53:20 EDT 2009
Neil Hodgson wrote:
> casebash:
>
>> I have searched this list and found out that Python doesn't have a
>> mutable string class (it had an inefficient one, but this was removed
>> in 3.0). Are there any libraries outside the core that offer this?
>
> I wrote a gap buffer implementation for Python 2.5 allowing
> character, unicode character and integer elements.
>
> http://code.google.com/p/gapbuffer/
>
> Its not seen much use or any maintenance so is unlikely to work with
> Python 3.x.
>
> Neil
I tried this as a learning exercise and found slicing doesn't work
correctly.
import gapbuffer
print gapbuffer.GapBuffer(range(10))[:]
GapBuffer('i')]
If my sleuthing is correct the problem is with these lines
ilow *= self->itemSize;
ihigh *= self->itemSize;
in GapBuffer_slice being computed before ilow and ihigh are compared to
anything.
Python 2.6.2 32 bit Windows.
--
Kindest regards.
Mark Lawrence.
More information about the Python-list
mailing list