[minor] many fixes to please flake8

In dev there are 922 flake8 alerts,
including 597 about tutorial handling
(flake8 ... | grep tutorial).

In the minor-changes branch before this commit,
there were 958 alerts, 630 about tutorial.

After the commit, 160 alerts, 13 about tutorial.

I left some alerts that could indicate potential
bugs I didn't know how to fix. The very first alert
about an unused 'user1' variable looks suspect for
example.