[docs] [issue20402] List comprehensions should be noted in for loop documentation

Rob Lanphier report at bugs.python.org
Mon Aug 4 05:57:44 CEST 2014


Rob Lanphier added the comment:

> Moving it earlier in the tutorial is likely to do more harm than help.
> In teaching Python, you need some gap between learning for-loops and 
> learning list comprehensions (the former is a prerequisite for the
> latter).

The problem here is that many people get list comprehensions foisted on them by reading code that has them in it.  Since list comprehensions aren't called "list comprehensions" in the code, but rather, they look like funny for loops, many people will turn to the for loop documentation, and as of this writing, they won't find anything.

There doesn't necessarily need to be the full example as in Alex's patch (though Alex's version seems fine to me), I think there should at least be some link to the list comprehension documentation, e.g. "It is also possible to prepend a function onto a 'for' loop.  This is a :ref:`list comprehensions <tut-listcomps>`, and is explained further in the next chapter."

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20402>
_______________________________________


More information about the docs mailing list