This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Julian
Recipients Julian
Date 2010-11-21.00:42:43
SpamBayes Score 6.646101e-07
Marked as misclassified No
Message-id <1290300165.3.0.545545019254.issue10476@psf.upfronthosting.co.za>
In-reply-to
Content
Iterating over a byte file object using __iter__ is rather useless, and a bit confusing perhaps.

It'd be nice to propose two things:

1. Having __iter__ raise an exception if the file was opened with the "b" flag.

2. Adding a new by_bytes() method to file objects, which would return an iterator that yielded the next byte in the file, introducing the ability to write a similar `for byte in byte_file_obj.by_bytes()` that is currently possible when iterating by line over non-byte files.

It's quite easy to do (2) currently, obviously, but perhaps it's worthy of consideration for inclusion.
History
Date User Action Args
2010-11-21 00:42:45Juliansetrecipients: + Julian
2010-11-21 00:42:45Juliansetmessageid: <1290300165.3.0.545545019254.issue10476@psf.upfronthosting.co.za>
2010-11-21 00:42:43Julianlinkissue10476 messages
2010-11-21 00:42:43Juliancreate