Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'argument': 0.05; 'subject:Python': 0.06; 'args': 0.07; 'ugly': 0.07; 'string': 0.09; 'arguments': 0.09; 'function,': 0.09; 'subject:How': 0.10; 'def': 0.12; 'be:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "skip:' 30": 0.19; 'written': 0.21; 'seems': 0.21; '>>>': 0.22; 'print': 0.22; '31,': 0.24; "aren't": 0.24; 'instance,': 0.24; 'subject:/': 0.26; '(for': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'too.': 0.31; 'fri,': 0.33; 'trouble': 0.34; 'sense': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'changing': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'ian': 0.60; 'first': 0.61; 'back': 0.62; "you've": 0.63; 'interest': 0.64; 'more': 0.64; '30,': 0.65; 'eyes': 0.78; 'hardly': 0.84; 'rusi': 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=Ms+Lanosh4oJDnVXxGs20n1SwF6rKo744jWAZXd24jk=; b=jl+t5WZWwDVWEJ22X4TnhRKqw/ghj7/O0dt5vUxeCdFjf6MmphIa/toTJZ4DUpXdG2 RqUjqFyi+8/tyVOASxlAtaSGoifVlYufB8Tne2V/LFTgDwm7dfyqaK02u/jvFOD39z5H IdfbHlWXIfonnrlZk/Ih1Z/F3QIyoFKXyabUdPuH153posjgHa32zXovA6gboDzxdGnn gKSPQEfF0LKUFyCWG+Sb/KRjNyR4n27GeRq/k7n0FP3x0Bspbzp+MMwAofXKV/GLEQ1e eQFaitqlVGA/eYFcueecJIll25KcnxfGoWxWzcnUW5DDqNpHMLYy2kmIS+6ucLHgb/ew fTxg== MIME-Version: 1.0 X-Received: by 10.220.111.133 with SMTP id s5mr6798265vcp.63.1369939482940; Thu, 30 May 2013 11:44:42 -0700 (PDT) In-Reply-To: References: <851ce96a-0223-42b0-8d99-902294c71f58@hc4g2000pbb.googlegroups.com> Date: Fri, 31 May 2013 04:44:42 +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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369939485 news.xs4all.nl 15913 [2001:888:2000:d::a6]:46410 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46529 On Fri, May 31, 2013 at 4:36 AM, Ian Kelly wrote: > On Wed, May 29, 2013 at 8:49 PM, rusi wrote: >> On May 30, 6:14 am, Ma Xiaojun wrote: >>> What interest me is a one liner: >>> print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in >>> range(1,10)]) for j in range(1,10)]) >> >> Ha,Ha! The join method is one of the (for me) ugly features of python. >> You can sweep it under the carpet with a one-line join function and >> then write clean and pretty code: >> >> #joinwith >> def joinw(l,sep): return sep.join(l) > > 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.) ChrisA