Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3000
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'args': 0.07; 'defaults': 0.07; 'subject:()': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'be?': 0.16; 'blah': 0.16; 'clobber': 0.16; 'rantingrick': 0.16; 'redundancy': 0.16; 'removed:': 0.16; 'settle': 0.16; 'vals': 0.16; 'subject:] ': 0.16; 'subject:skip:d 10': 0.18; 'url:blog': 0.18; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'mon,': 0.22; 'specified': 0.22; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'assuming': 0.29; 'list': 0.30; 'cc:addr:python.org': 0.31; 'skip:\xc2 20': 0.31; 'none': 0.36; 'case': 0.37; 'should': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'anything': 0.38; 'to.': 0.39; 'set': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'needing': 0.68; 'received:74.125.83': 0.69; 'subject:Request': 0.73; '11,': 0.77; 'swap': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=4h2sctDYeh34atrY7gYoOThgV0ul5ABqxw1R8gfjXeU=; b=X2MHjhD0yhmJEYb5R+jYG/a0sa5pJQhoR5vCEoCULnra8fuj120gkGrP95pS63Xs7y 0+loKsbLd5mjopr8dlg9qTfyS+KM8v4AkBpCnRzVAfyD5Fwapm4MD3xGnJu1Y75E730z WM/UODdVZYrGgGG9H0PTnuszpDUbv1O/EAs9Y= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; 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; b=MvE4pPPXvqevG5Z6M/a0mT5ZLMDqyzTyGXQNANetwEqnl2v1dzDhcBlvZNuNqa/Wpo h/PXudxbMjlAqqskoiFriO5NQXU+NT5jUzqGo5t6QB8hzJJNi7gtyEXTn0AF2N/iGQDH n81+XVQIaAKAs9yhrsL0+xv40q9GIIkiFYSf8= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <48897e75-c02c-43c7-9f46-39da4bcc406d@p16g2000vbi.googlegroups.com> |
| References | <48897e75-c02c-43c7-9f46-39da4bcc406d@p16g2000vbi.googlegroups.com> |
| Date | Mon, 11 Apr 2011 15:53:45 -0700 |
| X-Google-Sender-Auth | 8pIUirF5ejgS_JfYOMx2-8Wex4Q |
| Subject | Re: [Feature Request] dict.setdefault() |
| From | Chris Rebert <clp2@rebertia.com> |
| To | rantingrick <rantingrick@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.228.1302562428.9059.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1302562429 news.xs4all.nl 81475 [::ffff:82.94.164.166]:37323 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:3000 |
Show key headers only | View raw
On Mon, Apr 11, 2011 at 2:35 PM, rantingrick <rantingrick@gmail.com> wrote:
>
> setdefault should take **kw args in the case of needing to set
> multiple defaults at one time. I would even settle for an *arg list if
> i had to.
What would the return value be? dict.setdefault() doesn't currently
just return None you know.
> Anything is better than...
>
> d.setdefault(blah, blah)
> d.setdefault(blah, blah)
> d.setdefault(blah, blah)
> d.setdefault(blah, blah)
> if blah is not blah:
> d.setdefault(blah, blah)
The redundancy is easily removed:
defaults = {blah: blah, blah: blah, blah: blah, blah: blah}
defaults.update(d) # clobber defaults with specified vals
d = defaults # swap in, assuming not aliased
# if aliased, then instead:
# d.clear()
# d.update(defaults)
if blah is not blah:
d.setdefault(blah, blah)
Cheers,
Chris
--
http://blog.rebertia.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
[Feature Request] dict.setdefault() rantingrick <rantingrick@gmail.com> - 2011-04-11 14:35 -0700
Re: [Feature Request] dict.setdefault() Westley Martínez <anikom15@gmail.com> - 2011-04-11 15:16 -0700
Re: [Feature Request] dict.setdefault() MRAB <python@mrabarnett.plus.com> - 2011-04-11 23:41 +0100
Re: dict.setdefault() rantingrick <rantingrick@gmail.com> - 2011-04-11 19:58 -0700
Re: dict.setdefault() Westley Martínez <anikom15@gmail.com> - 2011-04-12 07:02 -0700
Re: [Feature Request] dict.setdefault() Chris Angelico <rosuav@gmail.com> - 2011-04-12 08:44 +1000
Re: dict.setdefault() Raymond Hettinger <python@rcn.com> - 2011-04-11 15:49 -0700
Re: [Feature Request] dict.setdefault() Chris Rebert <clp2@rebertia.com> - 2011-04-11 15:53 -0700
Re: [Feature Request] dict.setdefault() MRAB <python@mrabarnett.plus.com> - 2011-04-11 23:59 +0100
Re: [Feature Request] dict.setdefault() Tim Chase <python.list@tim.thechases.com> - 2011-04-11 18:25 -0500
Re: dict.setdefault() Raymond Hettinger <python@rcn.com> - 2011-04-11 17:17 -0700
csiph-web