Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; '21,': 0.07; 'only,': 0.07; 'python': 0.11; 'called,': 0.16; 'defined.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'immutable,': 0.16; 'permits': 0.16; 'sorts': 0.16; 'subroutine': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'pieces': 0.19; "python's": 0.19; 'value.': 0.19; 'code,': 0.22; 'rules': 0.22; 'byte': 0.24; 'source': 0.25; 'compiled': 0.26; 'task': 0.26; 'defined': 0.27; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'another.': 0.31; "d'aprano": 0.31; 'enforce': 0.31; 'once,': 0.31; 'purely': 0.31; 'steven': 0.31; 'styles': 0.31; 'fri,': 0.33; 'style': 0.33; 'created': 0.35; 'transaction': 0.35; 'johnson': 0.35; 'no,': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'building': 0.35; 'object,': 0.36; 'programming,': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'expect': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'transaction.': 0.60; 'free': 0.61; 'course': 0.61; 'simply': 0.61; "you're": 0.61; 'name': 0.63; 'here': 0.66; 'side': 0.67; '20,': 0.68; 'default': 0.69; 'attention!': 0.84; 'compiling': 0.84; 'strengths': 0.84; 'subject:Value': 0.84; '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=CIpIT3Ita0Y4kZU1pfGQlCtdnnDWfGtBs6ataipnTRY=; b=iI/X2o485zgmtU3aL4JOFJs1CTgdN0H6Depmav5XSAxM+o52ur+u/dUXM6wQlph+bP Wvjt9eeHrdqjNyt9ZTWCVY9rphiGvs7ZYPAVubsSzwYyLgIhOaHyeUZt5/11MtxmHofX SACfoBkTi18e0dL1ql2LIfamYj0moo6esThCg7OPpcdUOnUMN0R7F6X6zGDAm+ImP/oT MGOntgD2dXFgIX+Y4q/vF0atOB/1swQxpaLNXlRZFD6sY7ti/dzRc4R8Wa0pbyO7GKyb hnt9Ojrz3UKi9Rn6PbtIGMeeoWRnp+g4rPnPT0mZZtZv9YjqO5t1EVnNc77ONMHt6kUk 1yIg== MIME-Version: 1.0 X-Received: by 10.221.4.4 with SMTP id oa4mr4683402vcb.70.1371798650037; Fri, 21 Jun 2013 00:10:50 -0700 (PDT) In-Reply-To: References: <7e6361d5-6619-4aaa-adda-8b5f01bde57f@googlegroups.com> <447dd1c6-1bb2-4276-a109-78d7a067b442@d8g2000pbe.googlegroups.com> <2e92b4c7-31be-40d2-a906-ab19f3630dfa@googlegroups.com> <51c3a4f8$0$29999$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 21 Jun 2013 17:10:49 +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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371798652 news.xs4all.nl 15944 [2001:888:2000:d::a6]:53920 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48847 On Fri, Jun 21, 2013 at 1:16 PM, Rick Johnson wrote: > On Thursday, June 20, 2013 7:57:28 PM UTC-5, Steven D'Aprano wrote: >> Python functions are >> created *once*, when defined. The cost of building the >> function -- compiling the source code to byte code, >> assembling the pieces into a function object, binding it >> to a name -- happens once and once only, not every time >> you call the function. So it is reasonable to expect that >> since the function is defined once, so are any default >> arguments. >> > > Here you go again with this diversionary tactics! Of course > the function is only compiled once! Anything else would be > ludicrous. PAY ATTENTION! I'm not arguing that the damn > function should be compiled each time it's called, no, i am > arguing that each call to a subroutine should be a UNIQUE > TRANSACTION. That means that no state can be carried from > one transaction to another. Why should that be? Why is a subroutine not allowed to retain any state? You're free to write code in a purely functional style if you like - all objects must be immutable, all functions must have no side effects and simply return a value. That's not the only way to code, and it is *definitely* not a rule to be codified into Python. One of Python's strengths is that it permits many styles of programming, without shoehorning every programmer and every task into one model. Of course, RickPy 4000 is welcome to enforce all these sorts of inane rules if it likes. I shan't be using it if it does. ChrisA