s= "Name1=Value1;Name2=Value2;Name3=Value3"
dict(item.split("=") for item in s.split(";"))
{'Name1': 'Value1', 'Name2': 'Value2', 'Name3': 'Value3'}
sq = lambda x:x**2
num_list = [0,1,2,3,4,5,6,7,8,9]
list(map(sq,num_list))
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
list(filter(lambda n:n>0, [0,-1,3,-20]))
[3]
list(filter(lambda n:n, [True, True, True, False, True, True]))
[True, True, True, True, True]
my_unfiltered_list = [True, True, True, False, True, True, "hello"]
list(filter(lambda n:type(n)!= bool, my_unfiltered_list))
['hello']
from itertools import product
a = ["foo", "melon"]
b = [True, False]
c = [1,2,3]
list(product(a, b, c))
itertools.starmap
to run a list of arguments through a given function.¶import itertools
list(itertools.starmap(pow,[(2,2),(3,2),(4,2)]))
[4, 9, 16]