classes and __iter__

david.garvey at gmail.com david.garvey at gmail.com
Mon Jan 9 20:22:05 EST 2012


I see your meaning for __iter__ method.;)

On Mon, Jan 9, 2012 at 4:57 PM, david.garvey at gmail.com <
david.garvey at gmail.com> wrote:

> Thanks Ian & Chris for the conversation...
>
>
>
>
> On Mon, Jan 9, 2012 at 4:15 PM, Chris Rebert <clp2 at rebertia.com> wrote:
>
>> On Mon, Jan 9, 2012 at 3:30 PM, david.garvey at gmail.com
>> <david.garvey at gmail.com> wrote:
>> > Chris,
>> >
>> > Both a list and dict are both iterable.  I get a python dictionary
>> object of
>> > both iterables.;)
>>
>> No, you get a Python object with both iterables as instance variables.
>> Instance variables happen to be stored using a dict (which is
>> accessible as .__dict__), but that's to some extent an implementation
>> detail whose relevance here I fail to see. My point was that, as Ian
>> explained, your __iter__() method, as written, is horribly broken.
>>
>> > It is nice... but I don't know if this is good form?
>>
>> I'm confused as to why you wrote a class (particularly when its name
>> is an *action* rather than a noun; big red flag right there!) for your
>> task in the first place. I think you'd be best served by moving your
>> parsing code into a function and using a
>> http://pypi.python.org/pypi/sorteddict , which provides the
>> sorted-keys property you seemed to be trying to accomplish.
>>
>> Also, please avoid top-posting in the future. (See
>> http://en.wikipedia.org/wiki/Posting_style )
>>
>> Cheers,
>> Chris
>> --
>> http://rebertia.com
>>
>
>
>
> --
> David Garvey
>



-- 
David Garvey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120109/c2f73987/attachment-0001.html>


More information about the Python-list mailing list