Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82305
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <random832@fastmail.us> |
| 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; 'clean.': 0.09; 'expectation': 0.09; 'received:internal': 0.09; 'semantic': 0.09; 'subject:set': 0.09; 'def': 0.12; 'be:': 0.16; 'executed.': 0.16; 'lambda': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'subject:default': 0.16; 'subject:parameters': 0.16; 'subject:their': 0.16; 'subject:values': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; 'example': 0.22; 'equivalent': 0.26; 'header:In- Reply-To:1': 0.27; 'dec': 0.30; 'this.': 0.32; 'received:66': 0.35; 'false': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'from:no real name:2**0': 0.61; 'header :Message-Id:1': 0.63; 'skip:n 10': 0.64; 'different': 0.65; 'subject:get': 0.81; '2014,': 0.84; 'imperative.': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=mesmtp; bh=0vb+rjnkV6TjVF1HT5vFg+hwjrk=; b=bXG5eI X0z6BLFvfE8c3t6b+a/uZecFFX9H5kFZlLMxf+bI66aoxCz3kBKd3gFAS1/FEQJP B/HLYKcm/MeYZfDEDEW08ZKvvhs6hNhjYRsfCwl9cB9GhekRgf3cR2sty12GSRJs C8nWRL8tzXmAZZ8L0KzQEIUoISgZHRQzNOw+A= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:subject :date:in-reply-to:references; s=smtpout; bh=0vb+rjnkV6TjVF1HT5vF g+hwjrk=; b=h6ULTw5plA364WTOZhbIfPclgDEscsmPxgcVYeaCyF5PzxIW1DUd ssPEBnZ5Vb4gdRQe6ceLNDEfvJxidp9spgLXrV9zxMq1ac7jEMT+BT99QUltdCal S9ixcRIdHgfKI8q7Lv4WkcflS0vx/dsgCjYoYgTrI3DG2ekOCFI8HFo= |
| X-Sasl-Enc | wkVLb4MJtE9sEUf1hgZv0yT9QjpfAUZlHZCAG9PMqofF 1418236730 |
| From | random832@fastmail.us |
| To | python-list@python.org |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 7bit |
| Content-Type | text/plain |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-c5cca857 |
| Subject | Re: When do default parameters get their values set? |
| Date | Wed, 10 Dec 2014 13:38:50 -0500 |
| In-Reply-To | <bc561515-fe9d-41c1-bdda-7362e76aecdf@googlegroups.com> |
| References | <54866F2E.1765.complang@piz.noip.com> <54866F2E.1768.complang@piz.noip.com> <XnsA3FED89759430duncanbooth@127.0.0.1> <mailman.16782.1418166477.18130.python-list@python.org> <bc561515-fe9d-41c1-bdda-7362e76aecdf@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.16824.1418236733.18130.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418236733 news.xs4all.nl 2916 [2001:888:2000:d::a6]:60283 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 4308 |
| X-Received-Body-CRC | 1478800802 |
| Xref | csiph.com comp.lang.python:82305 |
Show key headers only | View raw
On Tue, Dec 9, 2014, at 21:44, Rustom Mody wrote:
> Nice example -- thanks.
> Elaborates the why of this gotcha -- a def(inition) is imperative.
> From a semantic pov very clean.
> From an expectation pov always surprising.
Of course, I used a lambda for this. The equivalent without would be:
def f():
def g(x={}):
return x
return g
Ultimately it's no different from when any non-immutable expression is
executed.
def f: return {'x': {}}
f()['x'] is f()['x'] # False
d = f()
d['x'] is d['x'] # True
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
When do default parameters get their values set? "bSneddon" <bsneddon@1:249/999.remove-cdt-this> - 2014-12-09 11:32 -0500
Re: When do default parameters get their values set? "Chris Angelico" <chris.angelico@1:249/999.remove-cdt-this> - 2014-12-09 11:32 -0500
Re: When do default parameters get their values set? "Dave Angel" <dave.angel@1:249/999.remove-cdt-this> - 2014-12-09 11:32 -0500
Re: When do default parameters get their values set? Duncan Booth <duncan.booth@invalid.invalid> - 2014-12-09 21:18 +0000
Re: When do default parameters get their values set? random832@fastmail.us - 2014-12-09 18:07 -0500
Re: When do default parameters get their values set? Rustom Mody <rustompmody@gmail.com> - 2014-12-09 18:44 -0800
Re: When do default parameters get their values set? random832@fastmail.us - 2014-12-10 13:38 -0500
Re: When do default parameters get their values set? Rustom Mody <rustompmody@gmail.com> - 2014-12-10 18:18 -0800
Re: When do default parameters get their values set? Chris Angelico <rosuav@gmail.com> - 2014-12-11 13:24 +1100
Re: When do default parameters get their values set? Rustom Mody <rustompmody@gmail.com> - 2014-12-10 18:50 -0800
Re: When do default parameters get their values set? Steven D'Aprano <steve@pearwood.info> - 2014-12-11 03:15 +0000
Re: When do default parameters get their values set? Rustom Mody <rustompmody@gmail.com> - 2014-12-10 19:26 -0800
Re: When do default parameters get their values set? Ben Finney <ben+python@benfinney.id.au> - 2014-12-11 14:49 +1100
Re: When do default parameters get their values set? Chris Kaynor <ckaynor@zindagigames.com> - 2014-12-11 09:10 -0800
Re: When do default parameters get their values set? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-12 09:51 +1100
Re: When do default parameters get their values set? random832@fastmail.us - 2014-12-11 15:44 -0500
Re: When do default parameters get their values set? "Tim Chase" <tim.chase@1:249/999.remove-cdt-this> - 2014-12-09 11:32 -0500
csiph-web