
On 6/29/2012 5:36 PM, Mike Graham wrote:
On Fri, Jun 29, 2012 at 4:32 PM, Georg Brandl g.brandl@gmx.net wrote:
so far there were no negative votes
As far as I know, Raymond Hettinger is the itertools maintainer and he has repeatedly objected to this idea in the past (e.g. http://bugs.python.org/issue6021 ). Hopefully we can get his input again.
See my other post on this thread. I think people should really spend a few minutes researching before posting repeated ideas. In this case, read the itertools doc to see if such a function exists. It does, in the recipes, as 'grouper'. Has anyone ever before proposed that the recipe be added as a function? Search the tracker for 'itertools grouper'. Besides #6021, there are also
http://bugs.python.org/issue1643 'Add group() to itertools'
Raymond: "Sorry, I'm not interested in adding this to the module. Discussions to- date on the subject seem to show more interest in playing with grouper variants than in actual use cases. While the recipe given in the docs is somewhat opaque, it runs at C-speed (zero trips around the eval- loop) and it is encapsulated in a re-usable function. Writing this in C does nothing to improve the situation. Also, when people like to play with variants, there is no general agreement on useful requirements (like fill-in behavior or raising an exception on uneven length inputs). Trying to write option to meet all needs (n=2, step=1) makes the code more difficult to learn and use -- see several variants in Alex's Python Cookbook. Another issue is that we have to be very selective about adding tools to the module. Each addition makes the overall toolset harder to use -- it is better to have a good set of basic building blocks."
http://bugs.python.org/issue13095 "Support for splitting lists/tuples into chunks"
Raymond: "These have been rejected before. There is always a trade-off in adding tools such as this -- it can take more time to learn and remember them than to write a trivial piece of code to do it yourself. Another issue is that people tend to disagree on how to handle an odd sized left-over group -- different use cases require different handling.
We're trying to keep the core toolset reasonably small so that python remains simple and learnable. That raises the threshold for adding new tools."
There are now 18 itertools, up from the original. Grouper, or any generic function, may not be the best for what one wants with a list. I proposed in my other post that we *do* need a new doc section or how-to on this topic. (I am working on an outline.)