====== NOTES FROM PYTHON WORKOUT BOOK ====== ==== SPLAT OPERATOR ==== Splat operator (aka ''*'') allows a function to receive any number or arguments. def mysum(*numbers): print(type(numbers)) # tuple mysum(1,2,3,4,5) # passing arbitrary number of arguments mysum(*[2,3,4,5,6]) # unpacking an iterable ==== GEERATORS ==== A generator expression looks just like a list comprehension but with parentheses instead of brackets: # List comprehension — builds a list [some_func(w) for w in s.split()] # Generator expression — produces values lazily (some_func(w) for w in s.split()) When you pass a generator directly as the only argument to a function, you can drop the extra parentheses: " ".join(some_func(w) for w in s.split()) # parens omitted (cleaner)