Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Reimer Newsgroups: comp.lang.python Subject: Re: for / while else doesn't make sense Date: Fri, 20 May 2016 20:47:27 -0700 Lines: 59 Message-ID: References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <44ec67e8-0c6e-54d9-c2fc-a4d9b78efb3d@icloud.com> <1198e259-0bbb-f18a-e8d1-114bc84bf24c@icloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de ULRnXUKepYzjMEDcIdUfygHfiwHfa4ysJSds+MWP5sGw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.04; '(b)': 0.07; '21,': 0.07; 'differently': 0.07; 'feature.': 0.07; 'javascript,': 0.07; 'behave': 0.09; 'derived': 0.09; 'integer,': 0.09; 'portable': 0.09; 'recommends': 0.09; 'ruby,': 0.09; 'statements': 0.09; 'subject:while': 0.09; 'bug': 0.10; 'python': 0.10; 'python.': 0.11; 'language,': 0.11; 'syntax': 0.13; 'languages,': 0.15; 'languages.': 0.15; '2016': 0.16; 'java.': 0.16; 'lisp': 0.16; 'lisp,': 0.16; 'loops': 0.16; 'macro': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'restricting': 0.16; 'rewritten': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; 'helper': 0.18; 'implementing': 0.18; 'string,': 0.18; 'language': 0.19; '>>>': 0.20; '(a)': 0.22; 'fine,': 0.22; 'minor': 0.22; 'programming': 0.22; 'am,': 0.23; 'code,': 0.23; 'seems': 0.23; 'sat,': 0.23; 'all.': 0.24; 'feature': 0.24; "i've": 0.25; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'figure': 0.27; 'not.': 0.27; 'received:17': 0.27; 'restrict': 0.27; 'idea': 0.28; 'looks': 0.29; 'another.': 0.29; 'assembly': 0.29; 'far,': 0.29; 'for,': 0.29; 'subset': 0.29; 'wasting': 0.29; 'allows': 0.30; "i'm": 0.30; 'that.': 0.30; 'code': 0.30; '(i.e.,': 0.30; 'probably': 0.31; 'another': 0.32; 'received:10.0.0': 0.32; 'language.': 0.32; 'maybe': 0.33; 'getting': 0.33; 'point': 0.33; 'problem': 0.33; 'common': 0.33; "d'aprano": 0.33; 'done,': 0.33; 'picking': 0.33; 'steven': 0.33; 'surely': 0.33; "i'll": 0.33; 'languages': 0.34; 'previous': 0.34; 'received:10.0': 0.34; 'gets': 0.35; 'trouble': 0.35; 'functions.': 0.35; 'level': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'possible.': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'thought': 0.37; 'wanted': 0.37; 'experience,': 0.38; 'thank': 0.38; 'end': 0.39; 'does': 0.39; 'unable': 0.39; 'easily': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'header:MIME-version:1': 0.60; 'ever': 0.60; 'high': 0.60; 'your': 0.60; 'share': 0.61; 'avoid': 0.61; 'back': 0.62; 'charset:windows-1252': 0.62; 'subject: / ': 0.63; 'different': 0.63; 'differences': 0.66; 'specializing': 0.76; 'forth': 0.79; 'satisfied': 0.83; 'blow': 0.84; 'compelling': 0.84; 'float,': 0.84; 'header:In-reply-to:1': 0.84; 'perspective,': 0.84; 'subject:else': 0.84; 'subject:sense': 0.84; 'uncertain': 0.84; 'dust': 0.91 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-05-20_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1605210048 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 In-reply-to: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1463802445; bh=Iv41LDuYbQCW7NR12wqCyNtrhVAZWphzMSMObUM6v/0=; h=Subject:To:From:Message-id:Date:MIME-version:Content-type; b=ItCaP2ORmpiJoYs0+cLGeb7Sxo026oD23z/ckqYbpjvwEpQuoNCbyB9UThYOzkpf7 kjoDRH4h8fBjkaJUeDZZIb7VqQ4thLVEFfRIELkKHAkDCUv4q16aSoW3FQqp3F0sDR nNITEdUY1Jnj9h5Gdbn18OIa2XGn7q73gl98axWc62nOGNoll0zoE8+DdMBdcioe1s 2KGmNTZ1Ta6L5QPAoL4jmvk461A5YA8ahkK1dOn7vvDmVM+LlBJAvvfaoDELLiBRIE 7DLIHM1E0VWwCAFq/7IX0p3kcStgecK3gAd9WslTPJbjoagxUNCiNOswMaBPZ6cq2t KFfFU26W1qd8g== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1198e259-0bbb-f18a-e8d1-114bc84bf24c@icloud.com> X-Mailman-Original-References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <44ec67e8-0c6e-54d9-c2fc-a4d9b78efb3d@icloud.com> Xref: csiph.com comp.lang.python:108889 On 5/20/2016 7:31 PM, Chris Angelico wrote: > On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer > 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.