[Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly
Alexandre Vassalotti
alexandre at peadrop.com
Wed Jul 18 22:32:57 CEST 2007
So, any decision on the proposed semantic change of truncate?
-- Alexandre
On 7/3/07, Alexandre Vassalotti <alexandre at peadrop.com> wrote:
> On 7/2/07, Guido van Rossum <guido at python.org> wrote:
> > Honestly, I think truncate() should always set the current position to
> > the new size, even though that's not what it currently does.
>
> Thought about that and I think that would be the best thing to do.
> That would avoid making StringIO unnecessary different from BytesIO.
> And IMHO, it is less prone to bugs. If someone wants to truncate while
> keeping the current position, then he will have to state is intention
> explicitly by saving the value of tell() and calling seek() after
> truncating.
>
> I also find the semantic make more sense too. For example:
>
> >>> s = StringIO("Good bye, world")
> >>> s.truncate(10)
> >>> s.write("cruel world")
> >>> s.getvalue()
> ???
>
> I think that should return "Good bye, cruel world", not "cruel world".
>
> So, does anyone else agree with this small semantic change of truncate()?
>
More information about the Python-3000
mailing list