The "loop and a half"

Chris Angelico rosuav at gmail.com
Fri Oct 6 14:43:51 EDT 2017


On Sat, Oct 7, 2017 at 4:55 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Personally, I think stdin is a bit lame as a stimulus source for an
> interactive program. That's not even what stdin is primarily meant for;
> stdin is meant to be the input data for a job. Similarly, stdout is
> meant to be the result of the computation. Stderr, then, is used to
> deliver optional diagnostic messages, ie, metainfo about the
> computation.
>
> For interaction with a human, you should look into frameworks like Qt or
> curses.

Qt is *massive* overkill for a lot of programs. Even curses is more
than you'd normally need. Stick to readline and have done with it.

Challenge: Take a reasonably competent computer programmer who's never
written a single line of Python code, and teach him/her how to use
Python in one working week (Mon-Fri). Your student must work mostly
solo, and you may meet with him/her once per day for one hour. At 5PM
on Friday, your student must demonstrate a fully-working project
written in Python; it must have some form of user interaction and
perform some kind of useful or semi-useful task.

Are you going to recommend that s/he master Qt as well as the Python
language itself?

And if you say "this task is impossible", that's fine. I'll have to
rewrite my history and erase the eighteen or twenty (I think) students
of mine that have done exactly that. A number of them used Flask to
create a web application (since they already had experience with web
app development using Node.js prior to this one-week challenge), one
did data analysis with output in matplotlib, and the rest all used
nothing but the console. Recently, I had three (out of seven) students
building adventure games, and they all had distinct styles and
dramatically different code models, but all of them followed a basic
"read from stdin, write to stdout" model. Their UIs literally
consisted of just input() and print() calls, letting them all
concentrate on the guts of the code.

Standard streams exist for a reason.

ChrisA



More information about the Python-list mailing list