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


Groups > comp.lang.python > #18716

Re: classes and __iter__

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.087
X-Spam-Evidence '*H*': 0.83; '*S*': 0.00; '>>>>': 0.09; 'def': 0.13; 'subject:classes': 0.16; 'cc:addr:python-list': 0.16; 'mon,': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'cheers,': 0.20; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail- vw0-f46.google.com': 0.23; 'cc:2**0': 0.24; 'do,': 0.25; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'class': 0.29; 'chris': 0.30; 'url:library': 0.31; 'idea': 0.32; 'received:209.85.212': 0.34; 'all.': 0.34; 'url:python': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'skip:_ 10': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'received:209': 0.40; '8bit%:84': 0.64; '2012': 0.67; 'relevant': 0.70; 'sender:addr:chris': 0.84; 'url:datamodel': 0.84; 'url:functions': 0.84; 'url:html#object': 0.84; 'url:reference': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/gHEvo4Jnxp/1xZ7hEEsNFkxpIZsJp83ZKppgaRuLxU=; b=d9YO0Pk8sbUBl2OA/qyaBWO+g+VYjUtjFfI7TQJ0hdglNdTdw9MwC/irny90yjR8Ov Y9hEBIDItlK694jEQ+1LdTIgXpPLhrns7a2fZFCt0R1FaVQjlnGZAAFAF0Evj1Uu0Ul8 9Pmq4gHreV9+GohVvtuqu9Ll/UG6ckGDMyT5g=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <CA+oqfxRF4Gm=hfWsHRZ0mG-v=QSuNS+ED72x+d2b-5CO6BnaqQ@mail.gmail.com>
References <CA+oqfxRF4Gm=hfWsHRZ0mG-v=QSuNS+ED72x+d2b-5CO6BnaqQ@mail.gmail.com>
Date Mon, 9 Jan 2012 15:17:48 -0800
X-Google-Sender-Auth CGi75eBlhyOnLaN6YJDnBR_lBoA
Subject Re: classes and __iter__
From Chris Rebert <clp2@rebertia.com>
To "david.garvey@gmail.com" <david.garvey@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4555.1326151071.27778.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326151071 news.xs4all.nl 6921 [2001:888:2000:d::a6]:45513
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18716

Show key headers only | View raw


On Mon, Jan 9, 2012 at 2:51 PM, david.garvey@gmail.com
<david.garvey@gmail.com> wrote:
<snip>
>>>> class Parse_Nagios_Header:
> ...     def __init__(self):
> ...         self.keylist = []
> ...         self.d = {}
<snip>
> ...     def __iter__(self):
> ...         return iter(self.keylist, self.d)

No idea what you're expecting this __iter__() to do, but it doesn't work at all.
Relevant docs:
http://docs.python.org/library/functions.html#iter
http://docs.python.org/reference/datamodel.html#object.__iter__

Cheers,
Chris

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


Thread

Re: classes and __iter__ Chris Rebert <clp2@rebertia.com> - 2012-01-09 15:17 -0800

csiph-web