Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18723
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'broken.': 0.07; 'method,': 0.07; 'seemed': 0.07; 'python': 0.08; 'url:pypi': 0.08; 'dict': 0.09; 'parsing': 0.09; 'variables.': 0.09; 'stored': 0.13; 'chris,': 0.16; 'form?': 0.16; 'relevance': 0.16; 'see.': 0.16; 'subject:classes': 0.16; 'cc:addr:python-list': 0.16; 'mon,': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'written,': 0.18; 'jan': 0.19; '(which': 0.19; 'cc:no real name:2**0': 0.20; 'cheers,': 0.20; 'trying': 0.21; 'wrote': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail- vw0-f46.google.com': 0.23; 'dictionary': 0.23; 'cc:2**0': 0.24; 'extent': 0.24; 'code': 0.25; "i'm": 0.26; 'function': 0.27; '(see': 0.28; 'message-id:@mail.gmail.com': 0.28; 'accessible': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'class': 0.29; 'url:wiki': 0.29; 'confused': 0.30; 'chris': 0.30; 'list': 0.32; 'rather': 0.33; 'that,': 0.33; 'object': 0.33; 'received:209.85.212': 0.34; 'flag': 0.34; 'moving': 0.35; 'url:python': 0.36; 'variables': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'using': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'fail': 0.39; 'url:en': 0.39; 'url:org': 0.39; 'why': 0.39; 'received:209': 0.40; 'your': 0.61; 'happen': 0.61; 'property': 0.63; 'here': 0.65; '2012': 0.67; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6M0XjWnF9ce6eijk4BIFGQIytwkWei2VzzwrYDe4dy8=; b=fdjG6YtvYd9oS1Ax+0JXgHDJtWzWsLj6gwPoFtgINhEX48oUL8d3o/f+nk1fzZ2Glx RWHGx6EiAKYJzQluxaArcjb72f/JkhgOAWczyGALYGBQnBsit+dVnlzi7qcpXwJ0xp3r fw2SX0uXVPO0o5DG/jgCcFwSApkEyz3ocn5DY= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <CA+oqfxSwaYd=84-Ykkp3dTzJgDoioWAWLDU1Ow0LmisZYjgp4A@mail.gmail.com> |
| 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> |
| Date | Mon, 9 Jan 2012 16:15:17 -0800 |
| X-Google-Sender-Auth | s6UJHwIV8epQWCHJXfsoZvKIrfk |
| Subject | Re: classes and __iter__ |
| From | Chris Rebert <clp2@rebertia.com> |
| To | "david.garvey@gmail.com" <david.garvey@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4562.1326154520.27778.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326154520 news.xs4all.nl 6955 [2001:888:2000:d::a6]:39635 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18723 |
Show key headers only | View raw
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: classes and __iter__ Chris Rebert <clp2@rebertia.com> - 2012-01-09 16:15 -0800
csiph-web