#
# 1. Iterable Comprehensions
#

# 1.1 Example: get a list of odd numbers
iterable = range(10)
# basic 4 liner style
odds = list()
for i in iterable:
    if i % 2 !=0:
        odds += [i]
# same as a list comprehension syntax:
odds_list_comp = [i for i in iterable if i%2 != 0]

# 1.2 template:
def transform(val):
    pass # or map the value into something

def keep_criteria(val):
    return True # return False to filter out

# list comprehension:
result = [trasform(x) for x in iterable if keep_criteria(x)]
# set comprehension:
result = {trasform(x) for x in iterable if keep_criteria(x)}
# dict comprehension:
result = {x: trasform(x) for x in iterable if keep_criteria(x)}

