On 5/20/2016 7:31 PM, Chris Angelico wrote:

On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer
<christopher_rei...@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).

I don't have a problem with (a) because the majority of the programming languages I've been exposed to have derived from the C language. No offense to the LISPers, but LISP is a historical curiosity that I might blow the dust off and take a look at someday. I'll probably learn assembly language before I ever look at LISP. :)

But I disagree with (b) on restricting myself to a common subset of ALL the programming languages. Pseudo code allows me to describe a program in very general details. Implementing a program in a programming language requires getting into very specific details. Of course, there are major and minor differences from language to language. If an oddball feature gets the job done, I'll use that. Or maybe not. If I'm uncertain about something, I'll keep going back and forth until I'm satisfied one way or another.

The else block tacked on to for and while loops in Python seems very oddball-ish to me. I've always strive to follow best practice whenever possible. The one book I've read -- and so far, the only book on that feature -- recommends not using it. Based on my previous experience, I don't disagree with that author's opinion. If I have a compelling reason to use it, I'll use it. Or I'll simplify it to use helper functions.

If I wanted to write portable code, I would have stayed with... Java. O_o

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to