Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18723 > unrolled thread
| Started by | Chris Rebert <clp2@rebertia.com> |
|---|---|
| First post | 2012-01-09 16:15 -0800 |
| Last post | 2012-01-09 16:15 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: classes and __iter__ Chris Rebert <clp2@rebertia.com> - 2012-01-09 16:15 -0800
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2012-01-09 16:15 -0800 |
| Subject | Re: classes and __iter__ |
| Message-ID | <mailman.4562.1326154520.27778.python-list@python.org> |
On Mon, Jan 9, 2012 at 3: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.;) 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
Back to top | Article view | comp.lang.python
csiph-web