Programming Idioms

I've been using the phrase "programming idiom" for years to describe a
short useful recurring code construct. I didn't realize that it was
officially "a thing" until doing a web search on the phrase years
later.

As our students grow from newbies on I think it's helpful for them to
see recurring and related patterns and programming idioms gives us a
name to apply to many beginner patterns. An early idiom might be
"finding the smallest in a list:"

Another is the very similar and more general "do something on every
item in a list:"

for i in range(len(dataset)):
# do something to or with dataset[i]

By talking about constructs like these as idioms it helps students see
and develop coding patterns. It also helps them to build mental
abstractions. Each of the above idioms are a few lines of code but
each are also a single concept. Students learn to think of them as the
concept.

When students learn about list comprehensions in python they'll
rewrite the "do something..." more like this: