News for hackers. Stuff that matters.
Re:The unknown features of Python's `operator` module by xrisk on Sunday August 08, 2021 @12:26PM (#28107872)
exhaust((file.close() for file in files)) works.
Re:The unknown features of Python's `operator` module by klyrs on Sunday August 08, 2021 @12:40PM (#28108015)
Like I said, contrived example. Though, it's a specific example of a more general pattern where you have a bunch of objects that you need to send a message to. You might use this for event handling in the guts of a game engine.
Re:The unknown features of Python's `operator` module by elteto on Sunday August 08, 2021 @04:30PM (#28109826)
I believe exhaust(file.close() for file in files) should work as well, no need for the extra parens.