Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46527

Re: How clean/elegant is Python's syntax?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'subsequent': 0.05; 'subject:Python': 0.06; 'ugly': 0.07; 'string': 0.09; 'arguments': 0.09; 'consistency': 0.09; 'function,': 0.09; 'subject:How': 0.10; 'def': 0.12; 'be:': 0.16; 'iterable,': 0.16; 'preserves': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "skip:' 30": 0.19; 'putting': 0.22; 'print': 0.22; 'subject:/': 0.26; '(for': 0.26; 'code:': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'compared': 0.30; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'interface': 0.32; 'older': 0.33; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'changing': 0.37; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'short': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'first': 0.61; 'back': 0.62; "you've": 0.63; 'interest': 0.64; 'more': 0.64; '30,': 0.65; 'natural': 0.68; 'eyes': 0.78; '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:from:date:message-id:subject:to :content-type; bh=sBhsDPexBS23kyVjwlWPNzuJ8h0cu8aQDJ8vFkJ0ujk=; b=C/RlDgwn2nIOP/QYDEFWFGx8bDu7SceRhnsuVuQ+7L5RKH7neEXvtyZWy+/fkwbKnM +u0gAffmvDY+LNtTwoAIbdHul2tn7hfGLN/0FOwlsWQ8LxVXnWFzkV1ffWlakSRc47kQ 8uMBcLm2Tql9tljl2p1Ja2SWvsrAmmLEqbAZH+N5I0v/Tt86lewqr2ZMUZPoAIyjvY7n q/PzSmB7boepNwqCnrPZ9jlbZLZ3FVcjta60Y/puym89nPAw2yR9WveQupYpL0qqZGHG ze0RunlOP/XsW3sAKplEo3npn1RfktK1OnlnPdSGj6v1r8HMzvUTNhfUQ1DQAICfeUpb BCMw==
X-Received by 10.66.144.98 with SMTP id sl2mr9946623pab.92.1369939054328; Thu, 30 May 2013 11:37:34 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <851ce96a-0223-42b0-8d99-902294c71f58@hc4g2000pbb.googlegroups.com>
References <CAGVx7UWXAFHSHq37Ep-Vk=cM2wYrEGHSUhNc8s43bCvj_VcVow@mail.gmail.com> <CAGGBd_oT=vqvPGZy+d1H=XHjdPCmYUxJMXAwii7WH845xrYybQ@mail.gmail.com> <mailman.2389.1369876474.3114.python-list@python.org> <851ce96a-0223-42b0-8d99-902294c71f58@hc4g2000pbb.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 30 May 2013 12:36:54 -0600
Subject Re: How clean/elegant is Python's syntax?
To Python <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2443.1369939057.3114.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369939057 news.xs4all.nl 15952 [2001:888:2000:d::a6]:40477
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46527

Show key headers only | View raw


On Wed, May 29, 2013 at 8:49 PM, rusi <rustompmody@gmail.com> wrote:
> On May 30, 6:14 am, Ma Xiaojun <damage3...@gmail.com> 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)

Putting the separator first feels more natural to me because I expect
the separator to usually be short as compared to the iterable, which
is often a longer expression (as is the case in both of your
subsequent usages).  Placing the separator first also preserves
consistency of interface with the str.join and bytes.join functions,
as well as the older string.join function.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: How clean/elegant is Python's syntax? Ma Xiaojun <damage3025@gmail.com> - 2013-05-30 09:14 +0800
  Re: How clean/elegant is Python's syntax? rusi <rustompmody@gmail.com> - 2013-05-29 19:49 -0700
    Re: How clean/elegant is Python's syntax? Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-30 12:36 -0600
      Re: How clean/elegant is Python's syntax? rusi <rustompmody@gmail.com> - 2013-05-30 11:47 -0700
      Re: How clean/elegant is Python's syntax? John Ladasky <john_ladasky@sbcglobal.net> - 2013-05-30 15:01 -0700
    Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-05-31 04:44 +1000
    Re: How clean/elegant is Python's syntax? Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-30 12:51 -0600
    Re: How clean/elegant is Python's syntax? MRAB <python@mrabarnett.plus.com> - 2013-05-30 20:38 +0100
    Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-05-31 07:28 +1000
    Re: How clean/elegant is Python's syntax? Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-31 09:43 -0600
    Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-06-01 04:52 +1000

csiph-web