[issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other
New submission from uglemat: Today there are list comprehensions, set comprehensions, dict comprehensions and then... there are generator expressions, which apparently was called 'generator comprehensions' in the original PEP, don't know why that was changed. Some questions arises: * Are generator expressions a type of list comprehension, or are generator expressions to be considered their own thing. * Does 'list comprehension' mean a type of comprehension that happens to return a list, or is it to be considered more of a general concept. I usually talk about 'list comprehension' as a type of comprehension, and 'generator expression' as another type of comprehension, and after investigating whether or not that is correct I couldn't find an answer. On the wikipedia article on list comprension (http://en.wikipedia.org/wiki/List_comprehension#Python) they list generator expressions as well, indicating that it's a type of list comprehension. I think there's a lot of confusion to be had here, and that the documentation should clarify what exactly is meant by 'list comprehensions', regardless of what happens to be the case. I haven't really a bug report before, so forgive me if I'm doing something wrong. :) -- assignee: docs@python components: Documentation messages: 194048 nosy: docs@python, uglemat priority: normal severity: normal status: open title: More elaborate documentation on how list comprehensions and generator expressions relate to each other versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue18612> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other
uglemat added the comment: Yeah I think the differences are pretty easy to comprehend. To be honest the reason I came here is that I had an argument where someone commented on my code (where I used a generator expression) saying something akin to "list comprehensions are nice", so I replied "actually, that's a generator expression, which are very similar but behave differently". The response was that the two concepts are one and the same. I couldn't really say that that's incorrect, but I think it's very confusing for beginners if people are talking about generator expressions like they are list expressions because they behave so differently and the documentation for list comprehensions doesn't mention generator expressions. I was kind of longing for a definite answer so I could say "Nay, thou shall differentiate between list comprehensions and generator expressions". Is it right to correct someone and say that generator expressions are in fact *not* generator expressions? Maybe I'm blowing this out of proport ions. :) -- versions: +Python 3.5 -Python 2.7, Python 3.3, Python 3.4 ___ Python tracker <http://bugs.python.org/issue18612> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other
uglemat added the comment: > Is it right to correct someone and say that generator expressions are in fact > *not* generator expressions? Ups, I meant "Is it right to correct someone and say that generator expressions are in fact *not* list comprehensions?" All these expressions and comprehensions are making me dissy :) -- ___ Python tracker <http://bugs.python.org/issue18612> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18612] More elaborate documentation on how list comprehensions and generator expressions relate to each other
uglemat added the comment: Yeah, I guess it's pretty obvious that generator expressions are not list comprehensions from the glossary. I'll close the bug. -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue18612> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com