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


Groups > comp.lang.python > #46531

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

References (1 earlier) <CAGGBd_oT=vqvPGZy+d1H=XHjdPCmYUxJMXAwii7WH845xrYybQ@mail.gmail.com> <mailman.2389.1369876474.3114.python-list@python.org> <851ce96a-0223-42b0-8d99-902294c71f58@hc4g2000pbb.googlegroups.com> <CALwzidkvPJFWh1csV+sC6mFb9bZFaft_T5e+5E49eHucBTf-hQ@mail.gmail.com> <CAPTjJmqHE_Ctyn5dEL3TeXaan4_cF9JUWHi_hMb2nyafhpn5CQ@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-05-30 12:51 -0600
Subject Re: How clean/elegant is Python's syntax?
Newsgroups comp.lang.python
Message-ID <mailman.2446.1369939917.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, May 30, 2013 at 12:44 PM, Chris Angelico <rosuav@gmail.com> wrote:
> On Fri, May 31, 2013 at 4:36 AM, Ian Kelly <ian.g.kelly@gmail.com> 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.

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