classes and __iter__

Ian Kelly ian.g.kelly at
Mon Jan 9 18:55:38 EST 2012

On Mon, Jan 9, 2012 at 4:30 PM, david.garvey at
<david.garvey at> wrote:
> Chris,
> Both a list and dict are both iterable.  I get a python dictionary object of
> both iterables.;) It is nice... but I don't know if this is good form?
> Should I be asking the duck question here?
>>>> print helo.__dict__

I think you're confused, which is probably why your question is so
confusing.  helo.__dict__ has nothing to do with iterables or the
__iter__ method of your class.  This is just the instance dictionary
of the "helo" object, which contains all the attributes stored on that

I'm still not sure exactly what it is that you're asking whether it is
"good form"?  I also don't know what the "duck question" is -- I
presume you're referring to duck typing ("Does it quack like a
duck?"), but I don't see how that is relevant to the code you posted.


More information about the Python-list mailing list