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


Groups > comp.lang.python > #18721

Re: classes and __iter__

References <CA+oqfxRF4Gm=hfWsHRZ0mG-v=QSuNS+ED72x+d2b-5CO6BnaqQ@mail.gmail.com> <CAMZYqRRmKxrp7v_9OKpNjjO-RSWovQ0o91Y4SkN55c4hjiw4uw@mail.gmail.com> <CA+oqfxSwaYd=84-Ykkp3dTzJgDoioWAWLDU1Ow0LmisZYjgp4A@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-01-09 16:55 -0700
Subject Re: classes and __iter__
Newsgroups comp.lang.python
Message-ID <mailman.4560.1326153370.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jan 9, 2012 at 4:30 PM, david.garvey@gmail.com
<david.garvey@gmail.com> 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__
[SNIP]

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
object.

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.

Cheers,
Ian

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


Thread

Re: classes and __iter__ Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 16:55 -0700

csiph-web