[Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly (original) (raw)
Alexandre Vassalotti alexandre at peadrop.com
Tue Jul 3 17:06:20 CEST 2007
- Previous message: [Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly
- Next message: [Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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()?
-- Alexandre
- Previous message: [Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly
- Next message: [Python-3000] StringIO/BytesIO in io.py doesn't over-seek properly
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]