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


Groups > comp.lang.python > #99031

Re: Question about 'print' in a loop

Newsgroups comp.lang.python
Date 2015-11-18 19:20 -0800
References <75f51ee1-907c-47c4-9be9-58241ff83115@googlegroups.com> <mailman.444.1447902665.16136.python-list@python.org>
Message-ID <9982d291-891a-4132-a0cf-2bc94b50d05f@googlegroups.com> (permalink)
Subject Re: Question about 'print' in a loop
From fl <rxjwg98@gmail.com>

Show all headers | View raw


On Wednesday, November 18, 2015 at 10:11:24 PM UTC-5, Chris Angelico wrote:
> 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

Excuse me. That is my unclear question.
I expect that each call sq will have one print 'here', as I suppose that
print 'here' is inside the loop.

Oh, I just realize that it is not a function. It constructs list sq.
When the loop (function as a constructor (not necessarily correct called),
it print 5 'here'.

Thanks for you feedback.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Question about 'print' in a loop fl <rxjwg98@gmail.com> - 2015-11-18 18:55 -0800
  Re: Question about 'print' in a loop Chris Angelico <rosuav@gmail.com> - 2015-11-19 14:11 +1100
    Re: Question about 'print' in a loop fl <rxjwg98@gmail.com> - 2015-11-18 19:20 -0800
  Re: Question about 'print' in a loop dieter <dieter@handshake.de> - 2015-11-19 08:31 +0100

csiph-web