Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75343
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <johannes.schneider@galileo-press.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'amtsgericht': 0.07; 'hrb': 0.07; "subject:' ": 0.07; 'referenced': 0.09; 'garbage': 0.16; 'rainer': 0.16; 'ralf': 0.16; 'scope,': 0.16; 'subject:break': 0.16; 'subject:generator': 0.16; 'subject:when': 0.16; 'terminate.': 0.16; 'wrote:': 0.18; 'gmbh': 0.22; 'rules': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'apply.': 0.24; 'germany': 0.24; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'guess': 0.33; 'subject:?': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'break': 0.61; 'received:194': 0.64; 'skip:+ 10': 0.65; 'tel.:': 0.65; 'here': 0.66; 'frank': 0.68; 'press': 0.70; 'received:192.168.57': 0.84; 'subject:you': 0.87 |
| Date | Tue, 29 Jul 2014 09:17:46 +0200 |
| From | Johannes Schneider <johannes.schneider@galileo-press.de> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: What happens when you 'break' a generator? |
| References | <lr7hsg$3pp$1@ger.gmane.org> |
| In-Reply-To | <lr7hsg$3pp$1@ger.gmane.org> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12410.1406620022.18130.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1406620022 news.xs4all.nl 2901 [2001:888:2000:d::a6]:42528 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75343 |
Show key headers only | View raw
On 29.07.2014 09:18, Frank Millman wrote: there's not print 'done' statement at the and. > Here I break the loop - > > x = test() > for j in x: > print(j) > if j == 2: > break > > Now the output is - > > start > 0 > 1 > 2 > > 'done' does not appear, so the generator does not actually terminate. What > happens to it? > > My guess is that normal scoping rules apply. Using my example, the generator > is referenced by 'x', so when 'x' goes out of scope, the generator is > garbage collected, even though it never completed. > > Is this correct? > > Frank Millman > > > -- Johannes Schneider Webentwicklung johannes.schneider@galileo-press.de Tel.: +49.228.42150.xxx Galileo Press GmbH Rheinwerkallee 4 - 53227 Bonn - Germany Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax) http://www.galileo-press.de/ Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker HRB 8363 Amtsgericht Bonn
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: What happens when you 'break' a generator? Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-07-29 09:17 +0200
csiph-web