classes and __iter__

Chris Rebert clp2 at rebertia.com
Mon Jan 9 18:17:48 EST 2012


On Mon, Jan 9, 2012 at 2:51 PM, david.garvey at gmail.com
<david.garvey at 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



More information about the Python-list mailing list