On Tue, Mar 17, 2015 at 7:14 PM, Dan Sommers <d...@tombstonezero.net> wrote: > On Wed, 18 Mar 2015 00:35:42 +0000, Mark Lawrence wrote: > >> I've just come across this >> http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of >> this http://bugs.python.org/issue23695 >> >> Any and all opinions welcomed, I'm chickening out and sitting firmly >> on the fence. > > According to the article itself, "it relies in an implementation detail > (the order the zip function iterates over the arrays) to work." Then > again, the article also points to the official docs that says that this > implementation detail is guaranteed. > > So it's no worse than depending on some weird but *documented* corner of > the IEEE-754 or POSIX spec.
In fact, this is also a code recipe found in the itertools documentation. The official docs don't just guarantee it; they *recommend* it. def grouper(iterable, n, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n return zip_longest(*args, fillvalue=fillvalue) https://docs.python.org/3.4/library/itertools.html -- https://mail.python.org/mailman/listinfo/python-list