Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'suppose': 0.05; 'args': 0.07; 'from:addr:python': 0.09; 'imho.': 0.09; 'overwrite': 0.09; 'subject:()': 0.09; 'am,': 0.14; 'wrote:': 0.14; '(key': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mrab': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'such,': 0.16; 'argument': 0.16; 'entries': 0.16; 'subject:] ': 0.16; 'subject:skip:d 10': 0.18; "wouldn't": 0.18; 'tue,': 0.20; 'header:In-Reply-To:1': 0.22; 'optional': 0.23; 'values.': 0.23; 'structure': 0.24; 'received:84': 0.25; "i'm": 0.26; 'chris': 0.27; 'to:addr:python-list': 0.32; 'wanting': 0.33; 'skip:" 10': 0.34; 'header:User-Agent:1': 0.35; 'reply- to:addr:python.org': 0.35; 'should': 0.37; 'apr': 0.38; 'pretty': 0.38; 'larger': 0.39; 'to:addr:python.org': 0.39; 'except': 0.39; 'would': 0.40; 'act': 0.61; '2011': 0.62; 'reply-to:no real name:2**0': 0.72; 'header:Reply-To:1': 0.72; 'subject:Request': 0.73 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8HAJuHo03Unw4S/2dsb2JhbACZBI0cd8MNhW4EkUI Date: Mon, 11 Apr 2011 23:59:33 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: python-list@python.org Subject: Re: [Feature Request] dict.setdefault() References: <48897e75-c02c-43c7-9f46-39da4bcc406d@p16g2000vbi.googlegroups.com> <1302560207.11756.1.camel@localhost.localdomain> <4DA38391.1040507@mrabarnett.plus.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 13 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302562770 news.xs4all.nl 81476 [::ffff:82.94.164.166]:38536 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3002 On 11/04/2011 23:44, Chris Angelico wrote: > On Tue, Apr 12, 2011 at 8:41 AM, MRAB wrote: >> I'm not sure that "setdefault" should take **kw args for this because >> of its existing argument structure (key + optional value). >> >> A new method like "updatedefault" may be better, IMHO. It would act >> like "update" except that it wouldn't overwrite existing values. > > Wouldn't x.updatedefault(y) be pretty much y.update(x) ? > I suppose it would, except that it wouldn't be in-place as such, and it wouldn't be as efficient if you're wanting to default only a few entries in a larger dict.