Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'programmer': 0.03; 'argument': 0.05; 'interpreter': 0.05; '21,': 0.07; '[1,': 0.09; 'arguments': 0.09; 'arguments,': 0.09; 'falls': 0.09; 'friday,': 0.09; 'works.': 0.09; 'python': 0.11; 'def': 0.12; 'assume': 0.14; 'thread': 0.14; '[none,': 0.16; 'challenge?': 0.16; 'cliff': 0.16; 'conclusion:': 0.16; 'confuse': 0.16; 'demonstrable': 0.16; 'docs.': 0.16; 'exception:': 0.16; 'exception?': 0.16; 'fits': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; "he'll": 0.16; 'hell.': 0.16; 'ignoring': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'mutable': 0.16; 'object()': 0.16; 'protecting': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'which,': 0.16; 'exception': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'differ': 0.19; "python's": 0.19; '>>>': 0.22; 'example': 0.22; 'programming': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'passes': 0.24; 'fine': 0.24; 'guys': 0.24; 'script': 0.25; 'posts': 0.26; 'this:': 0.26; 'pass': 0.26; 'least': 0.26; 'world,': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'resolution': 0.29; 'raise': 0.29; 'code': 0.31; 'existence': 0.31; 'proposing': 0.31; 'anyone': 0.31; 'probably': 0.32; '(most': 0.33; 'guess': 0.33; 'could': 0.34; 'something': 0.35; 'johnson': 0.35; 'received:84': 0.35; 'version': 0.36; 'responsible': 0.36; 'should': 0.36; 'january': 0.37; 'too': 0.37; 'clear': 0.37; 'e.g.': 0.38; 'handle': 0.38; 'to:addr:python- list': 0.38; 'little': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'real': 0.63; 'such': 0.63; 'soon': 0.63; 'happen': 0.63; 'holding': 0.65; 'world': 0.66; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reads': 0.68; 'said:': 0.68; 'default': 0.69; 'presented': 0.69; 'reply- to:no real name:2**0': 0.71; 'enjoy': 0.71; 'buddies': 0.84; 'case?': 0.84; 'examples.': 0.84; 'rage.': 0.84; 'reply- to:addr:python.org': 0.84; 'subject:Value': 0.84; 'gift': 0.85; '2013,': 0.91; 'cast': 0.91; 'rick': 0.93; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=RZapVTdv c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=Mpz3XJYojt8A:10 a=hSlIY0N4lP3x9z7fEQcA:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Fri, 21 Jun 2013 20:25:49 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Default Value 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> In-Reply-To: <7e1ed740-df18-4978-b11d-8ca9c4b5bd04@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371842756 news.xs4all.nl 15990 [2001:888:2000:d::a6]:34208 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48878 On 21/06/2013 19:26, Rick Johnson wrote: > On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote: >> It isn't clear to me from your posts what exactly you're >> proposing as an alternative to the way Python's default >> argument binding works. In your version of Python, what >> exactly would happen when I passed a mutable argument as a >> default value in a def statement? E.g. this: >> >> >>> a = [1, 2, 3] >> >>> a.append(a) >> >>> b = object() >> >>> def f(x = [None, b, [a, [4]]]): >> ... pass # do something >> >> What would you like to see the interpreter do in this case? > > Ignoring that this is a completely contrived example that has > no use in the real world, here are one of three methods by > which i can handle this: > > ============================================================ > The Benevolent Approach: > ============================================================ > 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! > What about this: def f(x=Foo()): pass # do something Should it raise an exception? Only if a Foo instance is mutable? How do you know whether such an instance is mutable? > ============================================================ > The Apathetic Approach: > ============================================================ > I could just assume that a programmer is responsible for the > code he writes. If he passes mutables into a function as > default arguments, and then mutates the mutable later, too > bad, he'll understand the value of writing solid code after > a few trips to exception Hell. > > ============================================================ > The Malevolent Approach (disguised as beneva-loon-icy): > ============================================================ > I could use early binding to confuse the hell out of him and > enjoy the laughs with all my ivory tower buddies as he falls > into fits of confusion and rage. Then enjoy again when he > reads the docs. Ahh, the gift that just keeps on giving! > How does the "Apathetic Approach" differ from the "Malevolent Approach"? > ============================================================ > Conclusion: > ============================================================ > As you can probably guess the malevolent approach has some > nice fringe benefits. > > You know, out of all these post, not one of you guys has > presented a valid use-case that will give validity to the > existence of this PyWart -- at least not one that CANNOT be > reproduced by using my fine examples. All you can muster is > some weak argument about protecting the lemmings. > > Is anyone up the challenge? > Does anyone here have any real chops? > > PS: I won't be holding my breath. > Speaking of which, on 11 January 2013, in the thread "PyWart: Import resolution order", you were asked: """Got any demonstrable code for Python 4000 yet?""" and you said: """I am working on it. Stay tuned. Rick is going to rock your little programming world /very/ soon.""" How soon is "/very/ soon" (clearly longer than 5 months), and how did you fix this "PyWart"?