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: 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 To: python-list In-reply-to: References: <2a25a54a-c60b-4811-9c6a-97c7f717dccb@hd10g2000vbb.googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --=-1309116241-978328-17896-2252-1-= Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: quoted-printable Excerpts from Thomas L. Shinnick's message of Sun Jun 26 14:53:21 -0400 2= 011: > 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 --=-1309116241-978328-17896-2252-1-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQEcBAEBCAAGBQJOB4dRAAoJEAFAbo/KNFvpOBkH/02mQjm7OTmIr+pRz4vWUYhW dFPzS5OJdAyVPvF4NSAGrDCBD7D5QkYTOvow+jz5zZ/b9veXAArb//XAKC6EjzdO GuzFoOCKo28YMQ611tLL02ZI/7moB69Ftc3K/zD4uSFOgEok0coOwrQyOti1hsgw er7W72SLsoRSeFqoreoGy8yXTOFdRT8SROgAoocVAgmyfGWgjVu2+cQoP5cONps2 Clwcgf0cXfcFsfyCYbyk6ZOmBxH+jDRrrvGPwIH3BnJt/8ECLfKRJNsquw81D9ti E5+yf7lkmZO+zRpEGzwmn0AEQoDah4U78pLuxOMlPvGZaympCAH+ubgfTHG0BYE= =W9Uf -----END PGP SIGNATURE----- --=-1309116241-978328-17896-2252-1-=--