============================= Day 9: Tuesday, Feb 4th, 2014 ============================= 0. Read the following two links: `what is WSGI `__, `Wikipedia on WSGI `__; skim `a stack overflow question `__ and `the WSGI PEP `__ 1. `Quiz: answer some questions `__ 2. What is StackOverflow anyway? Hey, and what's a PEP? 3. WSGI in practice; separation of concerns. `(Presentation.) `__ 4. Thinkin' 'bout functions. Fun with functions and callables -------------------------------- try1: what does the following code print, if placed in a file and executed? :: def f(n): return 3 * n def g(): return f value = g() print value(5) try2: what does the following code print, if placed in a file and executed? :: def g(n): def f(): return 8*n return f value = g(5) print value() try3: what does the following code print, if placed in a file and executed? :: class Klassy(object): def __init__(self, n): self.n = n def val(self): return 4*self.n k = Klassy(5) print k.val() try4: what does the following code print, if placed in a file and executed? :: class Klassy(object): def __init__(self, n): self.n = n def val(self): def g(m): return 3 * self.n + m return g k = Klassy(4) fn = k.val() print fn(3) try5: what does the following code print, if placed in a file and executed? :: class Klassy(object): def __init__(self, n): self.n = n def val(self): def g(m): return 3 * self.n + m return g k = Klassy(4) fn = k.val() k.n = 8 print fn(4) try6: what does the following code print, if placed in a file and executed? :: class Klassy(object): def __init__(self, n): self.n = n def __call__(self): return 5*self.n k = Klassy(5) print k() try7: what does the following code print, if placed in a file and executed? :: def some_function(other_fn, value): value = value*5 value2 = other_fn(value) return value2 def f(n): return n + 1 def g(m): return m - 1 print some_function(g, 5) print some_function(f, 4) try8: what does the following code print, if placed in a file and executed? :: global_value = 6 def some_function(other_fn, value): value = value*global_value value2 = other_fn(value) return value2 def f(n): return n + 1 def g(m): return m - 1 print some_function(g, 5) print some_function(f, 4) global_value = 2 print some_function(g, 5) print some_function(f, 4) .. how many have read a formal spec document? .. concept of encapsulation, separation of concerns