Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Question about 'print' in a loop Date: Thu, 19 Nov 2015 14:11:02 +1100 Lines: 12 Message-ID: References: <75f51ee1-907c-47c4-9be9-58241ff83115@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de nYIYgyTbAIqQ+A+CAd9JFgizlDrq/Oi+haINGiX53lmw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:Question': 0.05; "subject:' ": 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; '"this': 0.13; 'do,': 0.15; 'thu,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'should.': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.213.174': 0.29; 'asked': 0.29; 'print': 0.30; 'code': 0.30; 'received:google.com': 0.35; 'nov': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'why': 0.39; 'does': 0.39; 'your': 0.60; 'here.': 0.62; 'skip:n 10': 0.62; "'here'": 0.84; 'chrisa': 0.84; 'to:none': 0.91; 'why?': 0.91; 'thereafter': 0.93 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:cc :content-type; bh=8lPGmBe2vONZVdffAb4oyJg7iv0YaRtoJFpvMLNrhoY=; b=mQVfO44TwAJhaStZBS6sT2SP9EDXPgbtfv/wTGJJbk5tFVgoDZrfra/4QfLsdOKJua h5F9stfvccKdnP5Kk21CsQkAnjZa921yhEzVYc64dJs6Np4tqSNr4W6ZqTPV62KnRBVJ RjL4CVCz6K0kDT5/sC9yLoizYnscZnOTvaWonD6NxCl8dIX4YtGIo6+gACSBNmCvWiap uvfZLr74jHsJftWnQdiEQBnBb+/vHtpH9MdE3qm9l20Zm8v9JFh/gPzhoDtaa6VSdn8R w1sWQJwHaRd2I3TuKhKjk53aEFSG5rLBciiJO15JG2cVFZZk29KKS8mK3UTrLdtOdWXG WtWg== X-Received: by 10.50.183.11 with SMTP id ei11mr6968486igc.94.1447902662166; Wed, 18 Nov 2015 19:11:02 -0800 (PST) In-Reply-To: <75f51ee1-907c-47c4-9be9-58241ff83115@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99030 On Thu, Nov 19, 2015 at 1:55 PM, fl wrote: > There are only one time 5 'here' printed out, but there is no 'here' print > out in thereafter call sq[2]() etc. How to understand this phenomenon? Code does what code should. Before you ask for comprehension of "this phenomenon", why don't you tell us what you expect your code to do, and why? I just asked my non-programmer sister and she was completely unsurprised by what Python did here. ChrisA