Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64726
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; "subject:' ": 0.07; '[1,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'main():': 0.16; 'subject:between': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; '25,': 0.31; 'concern': 0.31; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'example,': 0.37; 'list': 0.37; 'pm,': 0.38; 'around.': 0.60; 'referred': 0.60; 'hang': 0.67; 'safe.': 0.84; 'to:none': 0.92 |
| 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=RXyFGk7S3vJknZfmsUcl5eaprwJ9le4kpBhiAVelmc0=; b=R2WyjRr44wwSueiZh/H36B0DOR4ecXo5KfUwyxWUYYMf0gulpxz/iaKLwVocehZhYR DX80o3gTk0SS8HKDAF9UtQHezJLK7vQXQ5cLp9/o3I/i4NqqCDPV/qStRfXfWWDEKpUg sT7OxykRxUBDKqUkHI6GOmPR1zUcJsCB2LbLT3fPZkkpXymx1Qvw0TZhnOGBr4kFV5hc YcxOr2nJ2LTp5elad+riSbj4Y7IOn0LBMa55B6AACFJrJGAF1CikZrm2Pg3s6xw00a24 VaPylyLVCzUOZ4V1a64RjeW80eP1Ws5ftWoLH37UMjKmNC521h8Mn72DhJzh7Sr9FQ25 Q0tg== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.204.4 with SMTP id ku4mr18560379pbc.66.1390632238833; Fri, 24 Jan 2014 22:43:58 -0800 (PST) |
| In-Reply-To | <6ad4232c-a8d9-4195-9edd-65c0e35923a7@googlegroups.com> |
| References | <6ad4232c-a8d9-4195-9edd-65c0e35923a7@googlegroups.com> |
| Date | Sat, 25 Jan 2014 17:43:58 +1100 |
| Subject | Re: should I transfer 'iterators' between functions? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.5967.1390632242.18130.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390632242 news.xs4all.nl 2921 [2001:888:2000:d::a6]:44565 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64726 |
Show key headers only | View raw
On Sat, Jan 25, 2014 at 5:37 PM, <seaspeak@gmail.com> wrote: > take the following as an example, which could work well. > But my concern is, will list 'l' be deconstructed after function return? and then iterator point to nowhere? > > def test(): > l = [1, 2, 3, 4, 5, 6, 7, 8] > return iter(l) > def main(): > for i in test(): > print(i) Perfectly safe. Python guarantees that nothing can ever point to "nowhere"; everything that might be looking for something else will hold a reference to it, so the thing referred to will hang around. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
should I transfer 'iterators' between functions? seaspeak@gmail.com - 2014-01-24 22:37 -0800 Re: should I transfer 'iterators' between functions? Chris Angelico <rosuav@gmail.com> - 2014-01-25 17:43 +1100 Re: should I transfer 'iterators' between functions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-25 06:45 +0000 Re: should I transfer 'iterators' between functions? Ned Batchelder <ned@nedbatchelder.com> - 2014-01-25 07:55 -0500 Re: should I transfer 'iterators' between functions? Ned Batchelder <ned@nedbatchelder.com> - 2014-01-25 07:56 -0500 Re: should I transfer 'iterators' between functions? Peter Otten <__peter__@web.de> - 2014-01-25 14:32 +0100
csiph-web