[item for item in iterable]
>>> my_list = [1, 2, 3]
>>> def add_one(n):
... return n + 1
>>> map(add_one, my_list)
[2, 3, 4]
>>> def is_even(n):
return True if n%2 == 0 else False
>>> filter(is_even, my_list)
[2]
>>> filter(is_even, map(add_one, my_list))
[2, 4]
>>> f = lambda arguments: returnvalue
>>> add_one = lambda n: n + 1
>>> add_one(1)
2
>>> (lambda n: n*2)(4)
8
>>> map(lambda n: n%2, [1,2,3,4])
[1,0,1,0]
>>> [i for i in range(5)]
[0, 1, 2, 3, 4]
>>> [i**2 for i in range(5)]
[0, 1, 4, 9, 16]
>>> [i for i in range(5) if i%2==0]
[0, 2, 4]
>>> [i**2 for i in range(5) if i%2==0]
[0, 4, 16]
>>> [(i,j) for i in (0,1) for j in (0,1)]
>>> square_lookups = {thing:thing**2 for thing in range(3)}
{0:0, 1:1, 2:4}
>>> square_lookups[2]
4
>>> [i*j for i in range(3) for j in range(3)] [0, 0, 0, 0, 1, 2, 0, 2, 4]
>>> {i*j for i in range(3) for j in range(3)} set([0, 1, 2, 4])
>>> tuple(i for i in range(3))
(0, 1, 2)
>>> (i for i in range(3))
<generator object <genexpr> at 0x...>