12.5. Comprehension Tuple

  • Tuple Comprehension vs. Generator Expression

  • More information in Generators

12.5.1. Long Syntax

>>> tuple(x+10 for x in range(0,5))
(10, 11, 12, 13, 14)

12.5.2. Short Syntax

  • There is no short syntax for Tuple Comprehension

  • Round brackets will create Generator Expression

>>> (x+10 for x in range(0,5))  
<generator object <genexpr> at 0x...>