Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8482
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <kb1pkl@aim.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'arguments': 0.05; 'parameter': 0.05; 'python': 0.08; '"default': 0.09; 'content- type:multipart/signed': 0.09; 'filename:fname piece:signature': 0.09; 'header:In-reply-to:1': 0.09; 'mutable': 0.09; 'subject:parameters': 0.09; '(link)': 0.16; 'abraham': 0.16; 'content-type:application/pgp-signature': 0.16; 'executed.': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname:signature.asc': 0.16; 'from:addr:kb1pkl': 0.16; 'from:name:corey richardson': 0.16; 'richardson': 0.16; 'once,': 0.19; 'to:name:python-list': 0.19; 'sfxlen:2': 0.19; 'language': 0.21; 'cc:2**0': 0.21; "aren't": 0.22; 'modify': 0.22; 'maybe': 0.22; 'cc:no real name:2**0': 0.22; 'discussion': 0.22; 'times,': 0.25; 'changed': 0.25; 'function': 0.26; "i'm": 0.27; 'objects': 0.28; 'discussed': 0.28; 'compile': 0.29; 'cc:addr:python.org': 0.30; 'example': 0.30; 'definition': 0.30; '-0400': 0.30; 'list).': 0.30; 'subject:?': 0.31; 'values': 0.31; "i'll": 0.31; 'list': 0.33; 'done': 0.33; 'does': 0.33; 'actually': 0.33; 'header:User- Agent:1': 0.34; 'instead': 0.34; 'to:addr:python-list': 0.34; 'received:71': 0.34; 'faq': 0.35; "isn't": 0.35; 'reference': 0.35; '(for': 0.36; 'certain': 0.36; 'url:python': 0.36; 'but': 0.37; 'some': 0.37; 'url:org': 0.38; 'received:64.12.206': 0.38; 'think': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'run': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'under': 0.39; 'determine': 0.40; 'did': 0.40; 'would': 0.40; 'more': 0.60; 'header:Message-Id:1': 0.61; 'received:172.29': 0.64; 'received:r1000.mx.aol.com': 0.64; 'email name:docs': 0.67; 'from:addr:aim.com': 0.67; 'jun': 0.67; 'freedom': 0.68; '"there': 0.84; '2011:': 0.84; 'amazing,': 0.84; 'difference.': 0.84; 'execution.': 0.84; 'subject:value': 0.84; 'subtitle': 0.84; 'url:reference': 0.84; 'received:172.29.41': 0.91 |
| Subject | Re: Default value for optional parameters unexpected behaviour? |
| From | Corey Richardson <kb1pkl@aim.com> |
| To | python-list <python-list@python.org> |
| In-reply-to | <A2.62.09596.320870E4@hrndva-omtalb.mail.rr.com> |
| References | <2a25a54a-c60b-4811-9c6a-97c7f717dccb@hd10g2000vbb.googlegroups.com> <BANLkTik3UP6j0z=+Ywq6LnTmKyhx_1mtrQ@mail.gmail.com> <A2.62.09596.320870E4@hrndva-omtalb.mail.rr.com> |
| Date | Sun, 26 Jun 2011 15:23:57 -0400 |
| User-Agent | Sup/0.12.1 |
| Content-Transfer-Encoding | 8bit |
| MIME-Version | 1.0 |
| Content-Type | multipart/signed; micalg="pgp-sha256"; boundary="=-1309116241-978328-17896-2252-1-="; protocol="application/pgp-signature" |
| x-aol-global-disposition | G |
| X-AOL-VSS-INFO | 5400.1158/71780 |
| X-AOL-VSS-CODE | scan_error |
| X-AOL-SCOLL-SCORE | 0:2:466347072:93952408 |
| X-AOL-SCOLL-URL_COUNT | 0 |
| x-aol-sid | 3039ac1d29024e07875d03aa |
| X-AOL-IP | 71.181.74.141 |
| Cc | docs@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.431.1309116265.1164.python-list@python.org> (permalink) |
| Lines | 61 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1309116265 news.xs4all.nl 4370 [::ffff:82.94.164.166]:34950 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8482 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Excerpts from Thomas L. Shinnick's message of Sun Jun 26 14:53:21 -0400 2011:
> See reference manual section 7.6 "Function definitions" under the
> discussion subtitle "Default parameter values are evaluated when the
> function definition is executed. "
> http://docs.python.org/reference/compound_stmts.html#function-definitions
>
> Yes, this is discussed in many places and many times, but why isn't
> it in the Python FAQ? Amazing, yes?
>
Well, to be fair, I don't think most people actually read the FAQ.
The FAQ does say:
"Default arguments can be used to determine values once, at compile
time instead of at run time. This can only be done for functions or
objects which will not be changed during program execution..."
And he did modify the list during program execution. However this
isn't exactly forthright if you aren't looking for it / know what
you're reading. I don't think it should be spilled out in detail but
maybe a "there are some tricks involved with mutable default
arguments (for example a list). Refer to the language reference
(LINK) for more details" would be useful.
But I'm not really certain that would make much of a difference.
I'll Cc this to docs@python.org.
--
Corey Richardson
"Those who deny freedom to others, deserve it not for themselves"
-- Abraham Lincoln
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Default value for optional parameters unexpected behaviour? Marc Aymerich <glicerinu@gmail.com> - 2011-06-26 11:28 -0700 Re: Default value for optional parameters unexpected behaviour? Shashank Singh <shashank.sunny.singh@gmail.com> - 2011-06-27 00:09 +0530 Re: Default value for optional parameters unexpected behaviour? Corey Richardson <kb1pkl@aim.com> - 2011-06-26 14:36 -0400 Re: Default value for optional parameters unexpected behaviour? Noah Hall <enalicho@gmail.com> - 2011-06-26 19:45 +0100 Re: Default value for optional parameters unexpected behaviour? Terry Reedy <tjreedy@udel.edu> - 2011-06-26 14:46 -0400 Re: Default value for optional parameters unexpected behaviour? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-26 12:21 -0700 Re: Default value for optional parameters unexpected behaviour? Corey Richardson <kb1pkl@aim.com> - 2011-06-26 15:23 -0400
csiph-web