snap shot from a random Python course (in vitro)
I sorta flubbed showing 'em how functions preserve state between calls in their default parameter values. Tried to do it on the fly. But it all worked out, a "teach me" moment (a student helped in the chat window). I talk about this in my lead-up to generators / coroutines (I cover send) in that we usually think of functions folding their tents and forgetting all state between calls, forgetting about this corner case, which I covered for the Hubble folks at STSCI (thanks again for the opportunity). Otherwise a smooth class. I have this "grand unification" segment in Session 07 where they know decorators, and then they know context managers (__enter__, __exit__), then generators as a kind of iterator (__iter__, __next__). Then right away, while the iron is still hot, we use a decorator to turn a generator into a context manager! I have this castle_game.py and castle_game2.py that do the same "can you guess the keyword?" game, the second version employing the decorated generator version of the quiz. Could be the epiphany of a pythonic lifetime (about 10 minutes? -- much shorter than a dog year). Thanks for covering all that in your Advanced Python (OST -- course material still on-line [1]). There's more stuff in contextlib I want to study before tomorrow night. I like smoothing the edges of new concepts with more context from Standard Library. For example after generators, we tour in itertools, scrolling through the docs, getting the flavor of what's there, me the babbling tour guide... See you in 2017. Kirby Cc: edu-sig Archive [1] http://archive.oreilly.com/oreillyschool/courses/courses.html#course_id_158 On Tue, Dec 6, 2016 at 8:50 AM, Steve Holden <steve@holdenweb.com> wrote:
That sounds like it could be fun - put me down! S
Steve Holden
On Tue, Dec 6, 2016 at 4:20 PM, kirby urner <kirby.urner@gmail.com> wrote:
Just signed up to teach Jan 17 - Feb 16-17, Tue/Thur. I that's a night you're in Portland, maybe you can co-star on that show (I run 6-10:30 PM).
Kirby
participants (1)
-
kirby urner