Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81699
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:text': 0.05; 'class,': 0.07; 'context': 0.07; 'subject:file': 0.07; 'cc:addr :python-list': 0.11; 'comparison.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'generator.': 0.16; 'iterator': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'cc:2**0': 0.24; 'class.': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'helpful.': 0.31; 'shoot': 0.31; 'subject:some': 0.31; "we're": 0.32; 'run': 0.32; 'quite': 0.32; 'received:google.com': 0.35; 'raising': 0.36; 'manager': 0.38; 'nov': 0.38; 'question,': 0.38; 'list,': 0.38; 'how': 0.40; 'more': 0.64; 'subject:over': 0.84; 'subject:via': 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=YmQogkq+d+HvmvM/h2dhQeNRMGJkJLL+68Tfedjd2/w=; b=PV2h6lKctJAO8qGfUlkuaJIxhgsaPyLh7vQJ8vJYkRNUTIM3Nt7WwckxlPwTt771Jy oMrIORcVJWFDtAnjVuiUnU0KBLMy9fK5iS244ie6Uu3HDjvmilD6GfRN0qUhHPP4bmP7 hmzqk79389OuRRQw7hFnuub/80HRu1eYtsXApMiQVJlVrltDBo+9Rk0v7pKda/CvINt2 wbuNmUmQMSIJxmmXZ0tzis+CS9QMDM01XkiO//TymMyXjlbmbN0YlTJ17qnsyKUidcn9 NTjzeyhlk4pCytvLHbNh7XOHXq5csRlI39//zYHCVCY2eByeyAnTkXHNRRe3xP4vONpQ CUdQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.64.143 with SMTP id g15mr35610752ici.59.1417197754491; Fri, 28 Nov 2014 10:02:34 -0800 (PST) |
| In-Reply-To | <87fvd3dxb7.fsf@elektro.pacujo.net> |
| References | <mailman.16405.1417187079.18130.python-list@python.org> <5478ab81$0$2879$426a34cc@news.free.fr> <mailman.16414.1417196454.18130.python-list@python.org> <87fvd3dxb7.fsf@elektro.pacujo.net> |
| Date | Sat, 29 Nov 2014 05:02:34 +1100 |
| Subject | Re: Iterate over text file, discarding some lines via context manager |
| 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.16415.1417197764.18130.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417197764 news.xs4all.nl 2927 [2001:888:2000:d::a6]:37527 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81699 |
Show key headers only | View raw
On Sat, Nov 29, 2014 at 4:55 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > I think the OP can learn from the comparison. One question, many > lessons: > > * Here's how you write a generator. > > * Here's how you write a context manager class. You run into those > quite often as well. > > * See how much more suitable a generator is in this case. > > No need to shoot down those who only try to be helpful. Since we're so good at it on this list, I will nit-pick: that's not a context manager class, that's an iterator class. A context manager has __enter__ and __exit__, an iterator has __iter__ (returning self) and __next__ (returning or raising StopIteration). ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Iterate over text file, discarding some lines via context manager "fetchinson ." <fetchinson@googlemail.com> - 2014-11-28 16:04 +0100
Re: Iterate over text file, discarding some lines via context manager "ast" <nomail@invalid.com> - 2014-11-28 18:06 +0100
Re: Iterate over text file, discarding some lines via context manager Dave Angel <davea@davea.name> - 2014-11-28 12:40 -0500
Re: Iterate over text file, discarding some lines via context manager Marko Rauhamaa <marko@pacujo.net> - 2014-11-28 19:55 +0200
Re: Iterate over text file, discarding some lines via context manager Chris Angelico <rosuav@gmail.com> - 2014-11-29 05:02 +1100
Re: Iterate over text file, discarding some lines via context manager Marko Rauhamaa <marko@pacujo.net> - 2014-11-28 20:04 +0200
csiph-web