Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'variables': 0.07; 'string': 0.09; 'appropriate.': 0.09; 'dan': 0.09; 'oop,': 0.09; "people's": 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; 'cc:name:python list': 0.16; 'choice,': 0.16; 'clear.': 0.16; 'culturally': 0.16; 'fine.': 0.16; 'get,': 0.16; 'imo,': 0.16; 'names?': 0.16; 'nod.': 0.16; 'pythonic': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; '\xa0what': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'cc:addr:python.org': 0.22; 'beauty': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'long,': 0.26; 'nearly': 0.26; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'direction': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'getting': 0.31; 'lines': 0.31; 'clever': 0.31; "d'aprano": 0.31; 'multiline': 0.31; 'perl': 0.31; 'steven': 0.31; 'anyone': 0.31; 'this.': 0.32; 'probably': 0.32; 'becomes': 0.33; 'fri,': 0.33; 'style': 0.33; 'could': 0.34; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'too': 0.37; 'turn': 0.37; 'being': 0.38; 'whatever': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'bad': 0.39; 'even': 0.60; 'issues,': 0.61; "you're": 0.61; 'first': 0.61; 'more': 0.64; 'temporary': 0.65; 'beautiful': 0.68; 'subject:One': 0.74; 'complex,': 0.84; 'stretch': 0.91; 'from.': 0.93; 'imagine': 0.93; 'refuse': 0.93; '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 :cc:content-type; bh=vZuJrNBEOC1cnL+NtpffeOVU+JFNTPkCcKyIEFnULJo=; b=cgVBq0WDXkEQ2hau3tEo0bL5ly+KUqB/BLQVX701sXKpoPSaT5/CAYSWYM1Tw+dunQ /CmWTMQ0FOWU4nkEAlC3mOpMFzUhs3XH9JRiHjtMuesCUORbC+J8f5DR9lP+AmY9AaNe n++szFGhnUmnKHbMIRlM6VWYL3ApiF+4GOOrPoBvB7/f8IAIkMlmOyO2vHUOEsriHq/8 IcxkjOyXC6LyqgOeZcO8N5kwfn5+3jEZkApaePS2KwVaxjGNNDiQOCBkdsRBTTv8d+1R Q4PRNGJCTLWiMx2Ii3asboVjOLjbczzK5YqoPB068RiICdeCHUA54RXnXziTmb7W0aXv ELgw== MIME-Version: 1.0 X-Received: by 10.194.78.77 with SMTP id z13mr6154528wjw.27.1386386407511; Fri, 06 Dec 2013 19:20:07 -0800 (PST) In-Reply-To: <52a282d1$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <52a282d1$0$30003$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 6 Dec 2013 19:20:07 -0800 Subject: Re: One liners From: Dan Stromberg To: "Steven D'Aprano" Content-Type: multipart/alternative; boundary=047d7bfcfc98575bc804ece93d75 Cc: Python List 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: 152 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386386415 news.xs4all.nl 2829 [2001:888:2000:d::a6]:49618 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61225 --047d7bfcfc98575bc804ece93d75 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Dec 6, 2013 at 6:07 PM, Steven D'Aprano < steve+comp.lang.python@pearwood.info> wrote: > On Fri, 06 Dec 2013 15:54:22 -0800, Dan Stromberg wrote: > > > Does anyone else feel like Python is being dragged too far in the > > direction of long, complex, multiline one-liners? Or avoiding temporary > > variables with descriptive names? Or using regex's for everything under > > the sun? > > All those things are stylistic issues, not language issues. Yes, I see > far too many people trying to squeeze three lines of code into one, but > that's their choice, not the language leading them that way. > Yes, stylistic, or even "cultural". > I refuse to apologise > for writing the one-liner: > > result = [func(item) for item in sequence] > > instead of four: > > result = [] > for i in range(len(sequence)): > item = sequence[i] > result.append(func(item)) > IMO, this is a time when the one liner is more clear. But if you start trying to stretch that to extremes, it becomes worse instead of better. > > > What happened to using classes? What happened to the beautiful emphasis > > on readability? What happened to debuggability (which is always harder > > than writing things in the first place)? And what happened to string > > methods? > > What about string methods? > A lot of things people do with regex's, could be done with string methods more clearly and concisely. The beauty of Python is that it is a multi-paradigm language. You can > write imperative, procedural, functional, OOP, or pipelining style (and > probably more). The bad thing about Python is that if you're reading > other people's code you *need* to be familiar with all those styles. > That's fine. That's appropriate. But I imagine any of these can be done with the intention of being more clever than clear. BTW, what's pipelining style? Like bash? > I'm pleased to see Python getting more popular, but it feels like a lot > of newcomers are trying their best to turn Python into Perl or > something, culturally speaking. They're probably writing code using the idioms they are used to from > whatever language they have come from. Newcomers nearly always do this. > The more newcomers you get, the less Pythonic the code you're going to > see from them. > Nod. --047d7bfcfc98575bc804ece93d75 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Fri, Dec 6, 2013 at 6:07 PM, Steven D'Aprano &= lt;steve+comp.lang.python@pearwood.info> wrote:
On Fri, 06 Dec 2013 15:54:= 22 -0800, Dan Stromberg wrote:

> Does anyone else feel like Python is being dragged too far in the
> direction of long, complex, multiline one-liners? =A0Or avoiding tempo= rary
> variables with descriptive names? =A0Or using regex's for everythi= ng under
> the sun?

All those things are stylistic issues, not language issues. Yes, I se= e
far too many people trying to squeeze three lines of code into one, but
that's their choice, not the language leading them that way.

Yes, stylistic, or even "cultural".
=
=A0
I refuse to apologise
for writing the one-liner:

result =3D [func(item) for item in sequence]

instead of four:

result =3D []
for i in range(len(sequence)):
=A0 =A0 item =3D sequence[i]
=A0 =A0 result.append(func(item))
<= div>IMO, this is a time when the one liner is more clear.=A0 But if you sta= rt trying to stretch that to extremes, it becomes worse instead of better.<= br>

> What happened to using classes? =A0What happened to the beautiful emph= asis
> on readability? =A0What happened to debuggability (which is always har= der
> than writing things in the first place)? =A0And what happened to strin= g
> methods?

What about string methods?
A lot of things peopl= e do with regex's, could be done with string methods more clearly and c= oncisely.

The beauty of Python is that it is a multi-paradigm language. You can
write imperative, procedural, functional, OOP, or pipelining style (and
probably more). The bad thing about Python is that if you're reading other people's code you *need* to be familiar with all those styles.

That's fine.= =A0 That's appropriate.=A0=A0 But I imagine any of these can be done wi= th the intention of being more clever than clear.
=A0
BTW, what's pipelining style?=A0 Like ba= sh?

> I'm pleased to see Python getting more popular, but it feels like = a lot
> of newcomers are trying their best to turn Python into Perl or
> something, culturally speaking.

They're probably writing code usin= g the idioms they are used to from
whatever language they have come from. Newcomers nearly always do this.
The more newcomers you get, the less Pythonic the code you're going to<= br> see from them.

Nod.

--047d7bfcfc98575bc804ece93d75--