Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(at': 0.04; 'argument': 0.05; 'subject:Python': 0.06; 'args': 0.07; 'string': 0.09; 'arguments': 0.09; 'function,': 0.09; 'subject:How': 0.10; 'def': 0.12; 'argument,': 0.16; 'argument.': 0.16; 'be:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'thu,': 0.19; 'starts': 0.20; 'written': 0.21; 'seems': 0.21; '>>>': 0.22; 'saying': 0.22; '31,': 0.24; "aren't": 0.24; 'instance,': 0.24; 'first,': 0.26; 'second': 0.26; 'least': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'easier': 0.31; 'too.': 0.31; 'sep': 0.31; 'trivial': 0.31; 'skip:c 30': 0.32; 'fri,': 0.33; 'trouble': 0.34; 'sense': 0.34; "can't": 0.35; 'agree': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'picking': 0.36; 'shorter': 0.36; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'changing': 0.37; 'list': 0.37; 'ends': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'short': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'expression': 0.60; 'ian': 0.60; 'simply': 0.61; 'first': 0.61; 'back': 0.62; "you've": 0.63; 'more': 0.64; '30,': 0.65; 'eyes': 0.78; 'hardly': 0.84; 'thing,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=lX7AUh9b/6GcCem/zDmk0vCMgund5HAtfavHBR0TFKk=; b=o0n1/9R0LAECDAGZSDtkGv5fmiHFD8I9M6wkLXh6sE6aKaF52mUfyBiyDWdMnR9ZQ8 SwCKlkbH5pGPNgk2nEoJqNxGy4vL/JBfeuo8+vJG7uAvTPjW1Bg1ZqqMq3vQgKE7Svbq tVADFh6Kr7cyEjSmGyVz4mrWzn1WJn/W00wC1+BWRoG19RBD6uMV4acKZc8ifl+sh+ZK khUNM+5N1+k35/R2OykuV8Sot7MJs3vfKlGZ/H7uRMoUbCR2kkf23OFkyqxQVmGwEEWM FeT6uwAspSf2Oyc1R23w6RdNwNvC7aQgyAZ0PNBFjwVT+0GDViPZGX/ss+tzConfO1K9 LunA== MIME-Version: 1.0 X-Received: by 10.52.117.16 with SMTP id ka16mr6092108vdb.43.1369949298144; Thu, 30 May 2013 14:28:18 -0700 (PDT) In-Reply-To: References: <851ce96a-0223-42b0-8d99-902294c71f58@hc4g2000pbb.googlegroups.com> Date: Fri, 31 May 2013 07:28:17 +1000 Subject: Re: How clean/elegant is Python's syntax? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369949301 news.xs4all.nl 15960 [2001:888:2000:d::a6]:34729 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46544 On Fri, May 31, 2013 at 4:51 AM, Ian Kelly wrote: > On Thu, May 30, 2013 at 12:44 PM, Chris Angelico wrote: >> On Fri, May 31, 2013 at 4:36 AM, Ian Kelly wrote: >>> I don't object to changing the join method (one of the more >>> shoe-horned string methods) back into a function, but to my eyes >>> you've got the arguments backward. It should be: >>> >>> def join(sep, iterable): return sep.join(iterable) >> >> Trouble is, it makes some sense either way. I often put the larger >> argument first - for instance, I would write 123412341324*5 rather >> than the other way around - and in this instance, it hardly seems as >> clear-cut as you imply. But the function can't be written to take them >> in either order, because strings are iterable too. (And functions that >> take args either way around aren't better than those that make a >> decision.) > > The reason I like having the shorter argument first (at least for > function calls) is for when I'm reading the code. If I'm interested > in the second argument, then to find it I have to scan over the first > argument. I would rather scan over something short like '\n' than > something longer like a list comprehension. It sounds like a trivial > thing, but it really does make it easier to find where an expression > starts and ends when the expression is short. Yes, I do agree with that argument. But there's more to picking argument order than simply "sort by predicted length" :) I'm not saying it's *wrong* to put sep first, just that it's not as clearly-and-obviously-the-one-right-way as you suggested. ChrisA