9.5. Comprehension Tuple

9.5.1. Rationale

  • Tuple Comprehension vs. Generator Expression

  • More information in Generators

9.5.2. Long Syntax

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

9.5.3. 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...>

9.5.4. Assignments