simple web server
python -m SimpleHTTPServer [port]
parse json
curl http://api.joind.in | python -mjson.tool
list comprehenson
int_list = [i for i in range(100)]
generator comprehenson
csv_gen = (row for row in open(file))
yield - will result in a generator object
generator functions - use yield instead of return
When the Python yield statement is hit, the programs suspends function execution and returns the yield value to the caller.When a function is suspended, the state of that function is saved`.
syntax
[on_true] if [expression] else [on_false]
example
def find_max(a,b):
return a if (a>b) else b
example
a,b=20,10
max = a if a > b else b
#max = 20
num = 1_0_0_0_0
#num = 10000
x = lambda a : a + 10
print(x(5))