Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'argument': 0.05; 'interpreter': 0.05; 'defaults': 0.07; '22,': 0.09; 'arguments': 0.09; 'def': 0.12; '[none,': 0.16; 'cliff': 0.16; 'exception:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'immutable,': 0.16; 'intrinsic': 0.16; 'mean,': 0.16; 'mutable': 0.16; 'wizard': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'restrictions': 0.19; 'script': 0.25; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'object.': 0.31; 'restricted': 0.31; 'know.': 0.32; 'supposed': 0.32; 'another': 0.32; '(most': 0.33; 'could': 0.34; 'johnson': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'right?': 0.36; 'to:addr:python-list': 0.38; 'that,': 0.38; 'little': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'tell': 0.60; 'great': 0.65; 'bothered': 0.68; 'nobody': 0.68; 'default': 0.69; '4:26': 0.84; 'subject:Value': 0.84; 'cast': 0.91; 'rick': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=36rjVHIEBAw35t0+5G8Yq3/J6hYiNgtKoiyAxX88ZSw=; b=dHQYFmehgC+eMHzi0wVDen0tqbfXhthV1qFQMttChc5MepWndeGaVu+BL1tIn9HegC 3ssJP9WCAPOsDMvKN9C/HleEC1tWOaouZyZWwEJYi1eiGJIYvCsY6XP5opU4kjecL8qv vERetfpE+2/N5WJF/clKv9v6mfpfS8qfxeT1iRWNtqcRz5obysFszBAQFRq1nqdXbYas mEkX4IRrLEQqmHqTDJTa6hlCNQ5jyFzLDtvqSAq1rTh3sPiYEfXE/lO6bYF/5E8qj+kR CNoUlyILPynFF4AzUKnrC/Zuje52Fh+ZRp+P8m7MG+8kpIu/RO95hY27GWeaUq2io0QJ U2+A== MIME-Version: 1.0 X-Received: by 10.58.249.236 with SMTP id yx12mr6517089vec.25.1371841679719; Fri, 21 Jun 2013 12:07:59 -0700 (PDT) In-Reply-To: <7e1ed740-df18-4978-b11d-8ca9c4b5bd04@googlegroups.com> References: <7e6361d5-6619-4aaa-adda-8b5f01bde57f@googlegroups.com> <447dd1c6-1bb2-4276-a109-78d7a067b442@d8g2000pbe.googlegroups.com> <2e92b4c7-31be-40d2-a906-ab19f3630dfa@googlegroups.com> <51c477dd$0$29999$c3e8da3$5496439d@news.astraweb.com> <565a1c8f-6fd9-4bab-9834-076eaea527f8@googlegroups.com> <7e1ed740-df18-4978-b11d-8ca9c4b5bd04@googlegroups.com> Date: Sat, 22 Jun 2013 05:07:59 +1000 Subject: Re: Default Value From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371841687 news.xs4all.nl 15883 [2001:888:2000:d::a6]:51390 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48875 On Sat, Jun 22, 2013 at 4:26 AM, Rick Johnson wrote: > I could cast a "virtual net" over my poor lemmings before > they jump off the cliff by throwing an exception: > > Traceback (most recent screw-up last): > Line BLAH in SCRIPT > def f(x = [None, b, [a, [4]]]): > ArgumentError: No mutable default arguments allowed! So tell me, oh Great and Powerful Wizard of Rick, how is the interpreter supposed to know which defaults are mutable? I mean, it's obviously some intrinsic property of the object. Somehow one thing is clearly immutable, another thing clearly isn't. Will there be a PyObject_IsImmutable() API? Oh! I know. Function argument defaults will now be restricted to int/float/tuple. That would do it, right? Nobody would be bothered by little restrictions like that, would they. ChrisA