Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97096
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '(so': 0.07; 'cc:addr :python-list': 0.09; 'creighton': 0.09; 'worked,': 0.09; 'python': 0.10; 'thursday,': 0.13; 'subject:python': 0.14; 'thu,': 0.15; '24,': 0.16; '>>on': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterating': 0.16; 'iteration': 0.16; 'loops': 0.16; 'wrote:': 0.16; 'laura': 0.18; 'nested': 0.18; '>>>': 0.20; 'student': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'sep': 0.22; 'suppose': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; '-0700,': 0.29; 'dictionary': 0.29; 'code': 0.30; "d'aprano": 0.33; 'steven': 0.33; 'similar': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'mapping': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'wanted': 0.37; 'version': 0.38; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'policy': 0.63; 'today': 0.65; 'saw': 0.77; 'batchelder': 0.84; 'chrisa': 0.84; 'me!': 0.84; 'utc-4,': 0.84; 'to:none': 0.91; 'habit': 0.91; 'write:': 0.91; 'not:': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=hHT9stw8j4IJz8RPr+S/wKbdRpt3XD0apap+KXvaKWc=; b=T9Rm5mtNSC1P+05R7nb9C64m3mt6Xe7stxOWFjeoLoErqN2E+XYwTYfINewLtf0DK+ kQvQ6s4Unet87He86/Ak/CMKpInY7cILMff3pWe1JgJCUAvVk/k1Nu+i3Ud2krHdjXlz aC5uUStLdQxQNVvtUABMt/yFSCTbLxFUeEHyW5O3J+6Pkssto7KUJs0LzKXTt+mke1ef C9oiYN8MXd4GC25mDTXI8A+AsObqwwddyeoK6h/xsPx6GbD+2z851IgwI/K/UiPpdOm2 nIzPC5paFSIOKk4T3sRbvOw+lwaYlz3P/R3P5niBQYy85LsslnV+igAzw8Xs7f+pTF3w jBBQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.178.145 with SMTP id cy17mr33165184igc.92.1443131342457; Thu, 24 Sep 2015 14:49:02 -0700 (PDT) |
| In-Reply-To | <201509242108.t8OL8wQs026851@fido.openend.se> |
| References | <560391ea$0$2885$c3e8da3$76491128@news.astraweb.com> <00884c56-4c94-406b-9902-b94dda9d66b3@googlegroups.com> <201509242108.t8OL8wQs026851@fido.openend.se> |
| Date | Fri, 25 Sep 2015 07:49:02 +1000 |
| Subject | Re: Idiosyncratic python |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.148.1443131740.28679.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443131740 news.xs4all.nl 23771 [2001:888:2000:d::a6]:38549 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97096 |
Show key headers only | View raw
On Fri, Sep 25, 2015 at 7:08 AM, Laura Creighton <lac@openend.se> wrote:
> In a message of Thu, 24 Sep 2015 13:46:27 -0700, Ned Batchelder writes:
>>On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano wrote:
>>> What are your favorite not-wrong-just-weird Python moments?
>>
>>I've seen this a number of times:
>>
>> dict_of_values.update({'key': some_value})
>>
>>why not:
>>
>> dict_of_values['key'] = some_value
>>
>>I've considered writing a Pylint plugin to flag these...
>>
>>--Ned.
>
> A student today had a similar version of this one:
>
> Every time he wanted to change the value of dictionary mapping he would
> write:
> w={'key': new_value}
> dict_of_values.update(w)
That's a new one on me! The oddest dictionary code any of my students
has come out with (so far!) was a slavish habit of always iterating
over them thus:
for k,v in some_dict.items():
where some_dict is the only part that changed. So everywhere through
the code - even in nested loops - all dictionary iteration used "k"
and "v".
But I suspect it's exactly the same. Saw some code somewhere, found
that it worked, used it. If you don't understand something, don't
change it... which is a good policy in general, I suppose :)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Idiosyncratic python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-09-24 16:02 +1000
Re: Idiosyncratic python Paul Rubin <no.email@nospam.invalid> - 2015-09-23 23:16 -0700
Re: Idiosyncratic python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-09-24 16:35 +1000
Re: Idiosyncratic python Ben Finney <ben+python@benfinney.id.au> - 2015-09-24 16:54 +1000
Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 11:08 +1000
Re: Idiosyncratic python Terry Reedy <tjreedy@udel.edu> - 2015-09-24 02:54 -0400
Re: Idiosyncratic python wxjmfauth@gmail.com - 2015-09-24 00:06 -0700
Re: Idiosyncratic python Laurent Pointal <laurent.pointal@free.fr> - 2015-09-24 19:50 +0200
Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-24 21:05 +0100
Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 11:12 +0200
Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-24 14:09 +0100
Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 16:07 +0200
Re: Idiosyncratic python Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 08:26 -0600
Re: Idiosyncratic python Chris Angelico <rosuav@gmail.com> - 2015-09-25 02:57 +1000
Re: Idiosyncratic python jmp <jeanmichel@sequans.com> - 2015-09-24 20:04 +0200
Re: Idiosyncratic python Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 12:19 -0600
Re: Idiosyncratic python Ned Batchelder <ned@nedbatchelder.com> - 2015-09-24 13:46 -0700
Re: Idiosyncratic python Laura Creighton <lac@openend.se> - 2015-09-24 23:08 +0200
Re: Idiosyncratic python Chris Angelico <rosuav@gmail.com> - 2015-09-25 07:49 +1000
Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 10:55 +1000
Re: Idiosyncratic python sohcahtoa82@gmail.com - 2015-09-24 15:32 -0700
Re: Idiosyncratic python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-25 00:40 +0100
Re: Idiosyncratic python Akira Li <4kir4.1i@gmail.com> - 2015-09-25 03:04 +0300
Re: Idiosyncratic python Steven D'Aprano <steve@pearwood.info> - 2015-09-25 10:08 +1000
csiph-web