[Edu-sig] "do" as a keyword
Vern Ceder
vceder at canterburyschool.org
Wed Dec 12 15:55:33 CET 2007
Brian Blais wrote:
> I find that when teaching beginning programmers, they usually think in
> "until" terms, and not "while" terms.
I haven't noticed that so much myself, actually... My students (grades
8-10) tend to think in fixed numbers of repetitions and the whole idea
of a flexible loop is a big jump for some. That may be age/development
related, though...
>
> they find the "while" logic to be unintuitive, and I often find myself
> feeling the same way: crafting it with the until logic, and then
> reversing it. Perhaps I should do as above, and do:
I would second Kirby's comment that "intuitive" in programming contexts
often means "what we're used to" or even "the way I do it". ;-)
> while True:
> Forward()
> if Touched(): break
>
> but somehow that feels wrong to me, like bypassing the point of the
> while: all that power to check for conditions, and you just use it to
> check True, and then use a break inside. It's readable, I guess, but
> not a programming construct I am immediately drawn to.
I agree with you here... except for event loops, where the while True:
syntax is exactly what you need.
Again, I'm with Kirby on Python's parsimony in control structures. A
repeat 0 to x times structure is more general than a repeat 1 to x times
structure, and having a special case for the latter wouldn't be
"Pythonic" as I grok the term...
Cheers,
Vern
--
This time for sure!
-Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vceder at canterburyschool.org; 260-436-0746; FAX: 260-436-5137
More information about the Edu-sig
mailing list