two ideoms at one blow: line-reading and regexp-matching
Remco Gerlich
scarblac at pino.selwerd.nl
Thu Feb 21 11:12:08 EST 2002
More information about the Python-list mailing list
Thu Feb 21 11:12:08 EST 2002
- Previous message (by thread): two ideoms at one blow: line-reading and regexp-matching
- Next message (by thread): two ideoms at one blow: line-reading and regexp-matching
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Paul Rubin <phr-n2002a at nightsong.com> wrote in comp.lang.python: > Gustavo Cordova <gcordova at hebmex.com> writes: > > > Next question: why is muddying the statement/expression distinction a > > > detriment? As opposed to the alternate view, that the > > > statement/expression > > > distinction is itself a detriment? > > > -- > > > > Or, if I may rephrase the question: > > > > Why is the statement/expression distinction a detriment, > > as opposed to the alternate view, that the statement/expression > > distinction is a virtue? > > Because we've already seen, assignments in expressions are useful. > And blurring the statement/expression distinction has proven quite > successful in languages like C and Lisp. Are you sure? writing 'if (a=3) {' must be the most common bug in C programs. I wouldn't call it successful. In fact, Python already caught three of those for me this week as syntax errors - that would have been bugs in C. Also, putting multiple conceptual things on one line isn't good for code clarity. > Anyway, language attempts to impose "morality" on programmers tend to > annoy programmers more than they makes code any cleaner. When Python flagged those typos this week, I was *happy*. > Maybe there's a principle to be found here: "design by FAQ". If newbies > keep arriving and asking over and over again "how do I do X?", maybe > there's a good reason for having a way to do X. We've seen that already > for augmented assignments. Most newbies tend to come from language X, think Python is great, except it isn't quite X - why block indentation when { } would work? Why 'self'? Why not assignments in expressions? Etc. Hollywood wanted to make a movie out of Pratchett's "Mort" book, but only if that morbid 'Death' character could be removed. The Python idiom for while (m := re.match('whee',x)): blah() is while 1: m = re.match('whee',x) if not m: break blah() And to me, an experienced Python programmer who hasn't really used other languages in quite a while, that looks *much* clearer than the one liner assignment-in-the-while version. It's a common pattern, and the eye recognizes it immediately. But in the end, neither of our subjective opinions matter - Guido's does. That's probably why this language is so great. -- Remco Gerlich
- Previous message (by thread): two ideoms at one blow: line-reading and regexp-matching
- Next message (by thread): two ideoms at one blow: line-reading and regexp-matching
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list