New submission from Julian <julian+python....@grayvines.com>: 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. ---------- components: IO messages: 121820 nosy: Julian priority: normal severity: normal status: open title: __iter__ on a byte file object using a method to return an iterator type: feature request versions: Python 2.7, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10476> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com