[Python-Dev] Rationale behind lazy map/filter (original) (raw)
Michael Selik mike at selik.org
Wed Nov 4 22:59:05 EST 2015
- Previous message (by thread): [Python-Dev] Second milestone of FAT Python
- Next message (by thread): [Python-Dev] Rationale behind lazy map/filter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm not suggesting restarting at the top (I've elsewhere suggested that many such methods would be better as an iterable that can be restarted at the top by calling iter() multiple times, but that's not the same thing). I'm suggesting raising an exception other than StopIteration, so that this situation can be detected. If you are writing code that tries to resume iterating after the iterator has been exhausted, I have to ask: why?
The most obvious case for me would be tailing a file. Loop over the lines in the file, sleep, then do it again. There are many tasks analogous to that scenario -- anything querying a shared resource. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20151105/8cd90771/attachment.html>
- Previous message (by thread): [Python-Dev] Second milestone of FAT Python
- Next message (by thread): [Python-Dev] Rationale behind lazy map/filter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]