On Wed, Apr 25, 2018 at 11:53 PM, Chris Angelico firstname.lastname@example.org wrote:
Well, true. The point isn't WHO you're dictating to, but that you can dictate it at all. "Hmm, let's see. Toss a 'foo colon-equals' in front of X, then print out what foo is." My day job involves a lot of helping students learn how to debug, so I say this kind of thing a lot (even if it's obvious to me what the problem is, because the student needs to learn debugging, not just be told what to fix). Refactoring just for the sake of a print call is overkill and potentially risky (if the student edits the wrong thing).
This is overstating things slightly... the best alternative to 'foo colon-equals' isn't risky refactoring so you can call print, it's a helper like:
def p(obj): print(obj) return obj
that you can sprinkle inside existing expressions.
Expecting new users to realize that this is possible, and a good idea, and to implement it, and get it right, while they're in the middle of being confused about basic python things, is not terribly reasonable, so it's probably underused. But there are ways we could address that.
-- Nathaniel J. Smith -- https://vorpus.org