Per Guido's suggestion, I am starting a new thread on this.

The itertools module documentation has a bunch of recipes that give various ways to combine the existing functions for useful tasks. [1]

The issue is that these recipes are part of the documentation, and although IANAL, as far as I can tell this means they fall under the Python-2.0 license. [2]  Normally using the Python-2.0 license is not a big deal because it is non-copyleft. You have to include the license text and explain what changes you made, which isn't a problem for any sizable use of Python code. 

The problem occurs for such small code snippets.  Again IANAL, but it seems you have to add the license text to the project, identify which parts of the code fall under that license, and document any changes you made to it.  This is a lot of work to use, in many cases, just one or two lines of code. 

I personally use one of the projects, like more-itertools, that implement these recipes together under the Python-2.0 license and thus segregate the license issues from the rest of my code base, but at least in my opinion this mostly defeats the purpose of making code snippets like available.

As I am not a lawyer, so I don't know the best approach to deal with this issue (if it is even desirable to deal with it).  And I know that there are other modules with recipes and other sorts of documentation with useful code, although the itertools ones are the ones I see mentioned the most.

[1] https://docs.python.org/library/itertools.html#itertools-recipes
[2] https://docs.python.org/license.html#psf-license-agreement-for-python-release