Message121820
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. |
|
Date |
User |
Action |
Args |
2010-11-21 00:42:45 | Julian | set | recipients:
+ Julian |
2010-11-21 00:42:45 | Julian | set | messageid: <1290300165.3.0.545545019254.issue10476@psf.upfronthosting.co.za> |
2010-11-21 00:42:43 | Julian | link | issue10476 messages |
2010-11-21 00:42:43 | Julian | create | |
|