diff -r 118d6f49d6d6 Doc/tutorial/datastructures.rst --- a/Doc/tutorial/datastructures.rst Fri Aug 01 17:49:24 2014 +0200 +++ b/Doc/tutorial/datastructures.rst Sat Aug 02 14:16:49 2014 +0300 @@ -620,6 +620,13 @@ >>> words ['defenestrate', 'cat', 'window', 'defenestrate'] +In other languages, :keyword:`for` loops are often used to populate a sequence with data. While this method works just as well in Python, it is often better to use a :ref:`list comprehensions `. For instance, suppose we want to have a list of byte values of the sequence 'abc'. We could get it as:: + + >>> bytevalues = [ord(x) for x in 'abc'] + >>> bytevalues + [97, 98, 99] + +The related concept of :ref:`generator expressions ` can also be used to achieve similar goals. .. _tut-conditions: