Friday, October 14, 2016

Shop Talk


Last night I met with my current crop of students for the eighth time, wondering if we might be in for some weather.  Apparently the media were full of rumors of an impending tropical storm, or the tail end of one, and indeed the Pacific coast of Oregon was already taking a pounding.

Two days before, as chronicled below, we'd experienced a significant power outage in Asylum District, causing drivers, pedestrians, cyclists to mutually encounter Chavez & SE Hawthorne with no traffic signals ("the robots were dead" as a South African might put it).

However by the time class rolled around, the valley was still, just getting more rain, not unusual in October, given our rainforest ecosystem.  "Rainforest" is recognized as a single word in Wikipedia, so I'll be adding it to my spellchecker, goodbye red wavy lines.  Speaking of which, I don't like typos in my tweets and will go back and delete some for that reason alone.

What we got to, in this class on Python programming, was a second pass through both decorators and context managers, as topics, first encountered on Tuesday.  Then I ripped back the veil to reveal some of the deep mysteries behind the keyword yield, one of two still giving problems on the quiz, the other being nonlocal.

I needed this running jump to reach my goal in the final segment, before the last lab:  using a decorator from contextlib to wring a decent context manager from a generator function.

Steve Holden covered all this in his O'Reilly School curriculum, meaning I'd iterated through this material for some years.

I'm no stranger to this area, in other words, and so act as a tour guide for those venturing this deeply into the Land of the Pythonistas (sounds like Florida, doesn't it?).

Python is not the only language to sport something called "decorator syntax", basically a way to transform the behavior of callables with other callables, at design time.  It's syntactic sugar really, but really useful syntactic sugar.

I'm working with Jasand Pruski on the quadray stuff a little.  Keeping my remarks on Synergetics to thumbed SMS messages and Tweets is good discipline.  All we're missing are polyhedron emoji.

Regarding the mysteries of yield, the story got deep when the send( ) method came along, and then throw() and close().

I'm grateful to David Beazley for helping me to disentangle and distill the concept of co-routine from what could be a big mess.  That little decorator he does to "prime the pump" i.e. take us to the first (yield) ready to accept a value, is most illuminating and worth passing on.

Today I hacked on thekirbster.pythonanywhere.com, a minimalist web application implemented in Pythonic Flask, a WSGI application.

I made the CSS a little tighter, organized the landing pages (yes, I still hand code HTML tables), and stuck a dashboard of navigation buttons across the top).  I'm deliberately using code cut and pasted from well known teaching sites, such as w3schools.com. I'm using the the Mars.2 Release (4.5.2) Build id: 20160218-0600 version of Eclipse in an effort to stay in practice with that capable IDE.

coroutines