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


Groups > comp.lang.python > #18716 > unrolled thread

Re: classes and __iter__

Started byChris Rebert <clp2@rebertia.com>
First post2012-01-09 15:17 -0800
Last post2012-01-09 15:17 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#18716 — Re: classes and __iter__

FromChris Rebert <clp2@rebertia.com>
Date2012-01-09 15:17 -0800
SubjectRe: classes and __iter__
Message-ID<mailman.4555.1326151071.27778.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web