Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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; 'explicitly': 0.04; 'subject:Python': 0.05; 'python': 0.09; 'be:': 0.09; 'modulo': 0.09; 'worse': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.10; 'anyway': 0.11; '>>': 0.16; 'evaluation;': 0.16; 'indent': 0.16; 'sequence:': 0.16; 'wrote:': 0.17; 'integer': 0.17; '>>>': 0.18; 'feb': 0.19; 'email addr:gmail.com>': 0.20; '"",': 0.22; '>>>': 0.22; 'cc:2**0': 0.23; '>': 0.23; 'needed.': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'to?': 0.27; 'message-id:@mail.gmail.com': 0.27; 'division': 0.29; 'indentation': 0.29; 'multiline': 0.29; 'style.': 0.29; 'skip:& 10': 0.29; 'stuff': 0.30; 'point': 0.31; 'file': 0.32; 'print': 0.32; 'traceback': 0.33; 'zero': 0.33; 'problem': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'fail': 0.35; 'doing': 0.35; 'too.': 0.35; 'there': 0.35; 'except': 0.36; 'but': 0.36; 'too': 0.36; 'does': 0.37; 'being': 0.37; 'skip:z 10': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'where': 0.40; 'your': 0.60; 'worth': 0.63; '"we': 0.84; '2013': 0.84; 'conditions,': 0.84; 'standards,': 0.84; 'dennis': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=iddZoKBRJyxgG4adaLw41fgeAZpeP08agkDFXjb8nKI=; b=SsXBQ++M3H6zr8RZWK1gUi1eAaU47ijrI8sSg7jsYBuzkRrJe1P/XATYExMINVq1sk fO5274TsB9JuZrlSFcSLT+LbtVWxM4DFxK5rrQftQvFVZU0jLjg49z/9OfmyoNFrvgSn JrIhXCPLHX1iuntNVF5H5Z/OP1dnpu96gCqZzpp7sCd2FGmS+yROLxgQtTCnA9qxTbUO M06prgwYimjWezq7KhVMFYYsrsroNFN0tZ79PWambXGtc8JIiGycIwUP//nNEzM/7wI8 7p7DXyJcYf+NSzoOSVTpwNGA/3+ymKdYOU9GR3OGei1ao0q2/gBTOXRg7YORgVAGrzFC fPNg== X-Received: by 10.152.102.177 with SMTP id fp17mr8548805lab.0.1361761228985; Sun, 24 Feb 2013 19:00:28 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <5127848B.1060004@gmail.com> <928d2cf7-728b-4f35-b8c9-4c9b958507e5@googlegroups.com> <61471a01-ee6e-4bc6-bd08-8696a31ec1eb@googlegroups.com> <512A796D.6070802@mrabarnett.plus.com> From: Joshua Landau Date: Mon, 25 Feb 2013 02:59:48 +0000 Subject: Re: Python Newbie To: Dennis Lee Bieber Content-Type: multipart/alternative; boundary=f46d0408d69b5296d304d683bed6 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: 148 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361761231 news.xs4all.nl 6952 [2001:888:2000:d::a6]:48013 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39868 --f46d0408d69b5296d304d683bed6 Content-Type: text/plain; charset=ISO-8859-1 On 25 February 2013 02:08, Dennis Lee Bieber wrote: > On Sun, 24 Feb 2013 21:58:36 +0000, Joshua Landau > declaimed the following in > gmane.comp.python.general: > > > > > > condition1 = long_condition_expression_1 > > condition2 = long_condition_expression_2 > > condition3 = long_condition_expression_3 > > > > if condition1 and condition2 and condition3: > > STUFF > > > > No multiline needed. If you have *many* conditions, then: > > > Except that Python does short-circuit evaluation; your scheme will > fail in some situations: > > >>> x = 0 > >>> if x != 0 and 32 / x > 4: > ... print "we passed" > ... > >>> c1 = x != 0 > >>> c2 = 32 / x > 4 > Traceback (most recent call last): > File "", line 1, in > ZeroDivisionError: integer division or modulo by zero > >>> > Yeah, well... context*. There are perfectly legitimate ways of doing that too. A simple one would be: > supercondition = ( > long_condition_expression_1 and > long_condition_expression_2 and > long_condition_expression_3 > ) > > if supercondition: ... Please note the problem of the original is that the indentation dedents and indents in too quick a sequence: > if ( > something_here): # Where do I indent this to? > something_else There are standards, but I don't like the style. I thought it worth mentioning as we were all being subjective anyway ;P. It's much worse than: > if something_here: something_else #on the same line which is already explicitly advised against. * By which I mean: fair point --f46d0408d69b5296d304d683bed6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 25 February 2013 02:08, Dennis Lee Bieber <wlfraed= @ix.netcom.com> wrote:
On Sun, 24 Feb 2013 21:58:36 +0000, Joshua Landau
<joshua.= landau.ws@gmail.com> declaimed the following in
gmane.comp.python.general:


>
> condition1 =3D long_condition_expression_1
> condition2 =3D long_condition_expression_2
> condition3 =3D long_condition_expression_3
>
> if condition1 and condition2 and condition3:
> =A0 =A0 STUFF
>
> No multiline needed. If you have *many* conditions, then:
>
=A0 =A0 =A0 =A0 Except that Python does short-circuit evaluation; you= r scheme will
fail in some situations:

>>> x =3D 0
>>> if x !=3D 0 and 32 / x > 4:
... =A0 =A0 print "we passed"
...
>>> c1 =3D x !=3D 0
>>> c2 =3D 32 / x > 4
Traceback (most recent call last):
=A0 File "<interactive input>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero
>>>

Yeah, w= ell... context*.

There are perfectly legitimate ways of doing that too.

A simple on= e would be:

> supercondition =3D (
> =A0 =A0=A0long_condition_expression= _1 and
> =A0 =A0=A0long_condition_expression_2 and
> =A0 =A0=A0long_condition_expression_3
> )
>
> if supercondition: ...

Please note the = problem of the original is that the indentation dedents and indents in too = quick a sequence:

> if (
> something_here): # Where do I indent th= is to?
> =A0 =A0 something_else

There are s= tandards, but I don't like the style. I thought it worth mentioning as = we were all being subjective anyway ;P. It's much worse than:

> if som= ething_here: something_else #on the same line

which is already explicitly advised= against.

* By = which I mean: fair point
--f46d0408d69b5296d304d683bed6--