for / while else doesn't make sense

Chris Angelico rosuav at gmail.com
Fri May 20 22:31:36 EDT 2016


On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer
<christopher_reimer at icloud.com> wrote:
> On 5/20/2016 3:43 PM, Steven D'Aprano wrote:
>
>> But the idea that you should avoid a Python feature while programming in
>> Python because Javascript doesn't have it, or Ruby, or C, is surely the
>> height of muddleheaded thinking. You're not programming Javascript, Ruby
>> or
>> C, you're programming in Python. The whole point of picking one language
>> over another is to get access to the tools and features that language
>> offers. Otherwise you're just wasting your time.
>
>
> For many years I have resisted specializing in a programming language, as I
> can easily write any program in pseudo code and figure out the syntax for a
> particular language. Now it does help that most languages have derived from
> C and share a common feature set (i.e., string, integer, float, if/else,
> while, for, etc.). From my perspective, tacking on an else block to the end
> of a for or while loop looks like a bug or a not very well thought out
> feature. If I was translating a Python program with for/else or while/else
> statements into a different language, those statements will have to be
> rewritten anyway.

That's fine, as long as you (a) restrict your programming languages to
those derived from C, and (b) restrict your programming style to the
common subset of them all. Trouble is, that "common subset" is
actually pretty small. Strings behave very differently in C and high
level languages, and for loops are *very* different in different
languages. So you'd be throwing out a large amount of expressiveness,
plus you're completely unable to use languages built on some other
model (eg LISP, or DeScribe Macro Language, or APL).

ChrisA



More information about the Python-list mailing list