[Python-Dev] Why does read() return bytes instead of bytearray?

2009-04-14 Thread Dan Eloff
Hi, Can someone please explain why read() should return an immutable bytes type instead of a mutable bytearray? It's not like read() from a file and use buffer as a key in a dict is common. Certainly read() from file or stream, modify, write is very common. I don't understand why the common case p

[Python-Dev] Why does read() return bytes instead of bytearray?

2009-04-14 Thread Dan Eloff
>No, the read() method did not change from the 2.x series. It returns a new >object on each call. I think you misunderstand me, but the readinto() method looks like a perfectly reasonable solution, I didn't realize it existed, as it's not in the library reference on file objects. Thanks for enlig

[Python-Dev] Thank you all

2006-09-15 Thread Dan Eloff
I was just browsing what's new in Python 2.5 at http://docs.python.org/dev/whatsnew/ As I was reading I found myself thinking how almost every improvement made a programming task I commonly bump into a little easier. Take the with statement, or the new partition method for strings, or the defaultd