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


Groups > comp.lang.python > #18716

Re: classes and __iter__

References <CA+oqfxRF4Gm=hfWsHRZ0mG-v=QSuNS+ED72x+d2b-5CO6BnaqQ@mail.gmail.com>
Date 2012-01-09 15:17 -0800
Subject Re: classes and __iter__
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.4555.1326151071.27778.python-list@python.org> (permalink)

Show all headers | 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