Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'output': 0.05; 'subject:Python': 0.06; 'utf-8': 0.07; 'spaces': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(same': 0.16; 'be:': 0.16; 'block.': 0.16; 'indent': 0.16; 'semicolon': 0.16; 'think.': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'bit': 0.19; 'file,': 0.19; 'command': 0.22; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'instance,': 0.24; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'dos': 0.30; 'errors': 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'supposed': 0.32; 'running': 0.33; 'sense': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'wrong': 0.37; 'so,': 0.37; 'window': 0.38; 'pm,': 0.38; 'anything': 0.39; 'called': 0.40; 'most': 0.60; 'from:charset:utf-8': 0.61; 'first': 0.61; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; '8bit%:43': 0.74; 'it\xe2\x80\x99s': 0.84; 'urge': 0.91; 'works!': 0.91; 'url:tk': 0.95; '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:content-transfer-encoding; bh=54JPcXMdyUmZSIh5UTnsR+qdfUqFBWqVYZKG8TdxLaI=; b=fKIvGdoKMFJy+x2ZN6vIWJb+VmJTIKoZeGgX6Gd/4mFUKMwVjVCzADFhh+l0z3UGro sngwRQ0BCTJbrP8tCPdBXFqFn0VrKMa+7iXNwSSc2QbxbnHLPPjxEt8Wgs5zSekecVwa QxFz/d72jK5Hh5Nlsr4Q+xu9IvLnPDRzUTll5e5E/qkhguG6zJePLEnEnM+SvFErrcui vsgaGTRGWGcaTYDH+wbiJc7oHU9fAtL1ETLpgFDqPqsAb7HySg1SIIs8t5T/thHqKhs1 x1ZYWhka779KDwEOR7iZ/ON1baYNFufRClCKFpkES5gC7v7GxKb3AZCo0PVtsqAx8am3 8iXA== MIME-Version: 1.0 X-Received: by 10.50.114.168 with SMTP id jh8mr5526258igb.6.1382888438890; Sun, 27 Oct 2013 08:40:38 -0700 (PDT) In-Reply-To: <96fc985d-725e-4fe7-8d30-0bcaad91f975@googlegroups.com> References: <96fc985d-725e-4fe7-8d30-0bcaad91f975@googlegroups.com> Date: Sun, 27 Oct 2013 16:40:38 +0100 Subject: Re: indentation blocking in Python From: =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= To: ajetrumpet@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382890138 news.xs4all.nl 15980 [2001:888:2000:d::a6]:40083 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57750 On Sun, Oct 27, 2013 at 4:31 PM, wrote: > hello all, > > This has got me a tad bit confused I think. I am running 3.3.0 and I kno= w that Python looks to group code together that is supposed to be in the sa= me block. But the question is, where are the rules for this? For instance= , if I type the following in a PY file, it errors out and I don't see the D= OS window with the output in Vista: It=E2=80=99s called the command prompt. > a=3D1; > if a=3D=3D1: print(1) > else: print(0) > wait =3D input("press key") > > However, if I don't indent anything at all, it works! > > a=3D1; > if a=3D=3D1: print(1) > else: print(0) > wait =3D input("press key") You indented the wrong thing. You put your if/else statement in a non-standard way (which works, but is discouraged). Also, you ended the first line with a semicolon (same case). So, the proper code would be: a=3D1 if a=3D=3D1: print(1) else: print(0) wait =3D input("press key") (I resisted the urge to add spaces around `=3D` and `=3D=3D`, something mos= t people want you to do.) --=20 Chris =E2=80=9CKwpolska=E2=80=9D Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense