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 enlightening me, I feel a little stupid now :)
Python 3, lookout, here I come!
-Dan
On Tue, 14 Apr 2009 at 22:05, Dan Eloff wrote:
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 enlightening me, I feel a little stupid now :)
You have to follow the link from that section to the 'io' module to find it.
The io module is about streams and is therefore in the 'generic operating system services' section, not the 'file and directory access section', which makes it a little harder to find when what you think you want to know about is file access...I think this is a doc bug but I'm completely unsure what would be a good fix.
--David
2009/4/15 R. David Murray rdmurray@bitdance.com:
On Tue, 14 Apr 2009 at 22:05, Dan Eloff wrote:
>
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 enlightening me, I feel a little stupid now :)
You have to follow the link from that section to the 'io' module to find it.
The io module is about streams and is therefore in the 'generic operating system services' section, not the 'file and directory access section', which makes it a little harder to find when what you think you want to know about is file access...I think this is a doc bug but I'm completely unsure what would be a good fix.
I've added a like to the io module in the see also section of the file and directory systems.
-- Regards, Benjamin
On Wed, Apr 15, 2009 at 12:05 AM, Dan Eloff dan.eloff@gmail.com wrote:
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 enlightening me, I feel a little stupid now :)
However, your original question is still valid ... Why a binary read() returns an immutable type?
--
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594
Lisandro Dalcin <dalcinl <at> gmail.com> writes:
However, your original question is still valid ... Why a binary read() returns an immutable type?
Because bytes is the standard type for holding binary data. Bytearray should only be used when there's a real, measured performance advantage doing so (which, IMHO, is rarer than you think). An immutable type makes daily programming much less error-prone.
Regards
Antoine.