Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Date: Wed, 25 Nov 2015 09:14:48 +0100 Lines: 38 Message-ID: References: <87d1v5emhl.fsf@elektro.pacujo.net> <564e6a62$0$1620$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de MkSvBuA4hSQwBtenV7LtUgyHFrbq+ml+omssRE6pBa2g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:134': 0.05; 'executed': 0.07; 'behave': 0.09; 'creighton': 0.09; 'def': 0.13; 'subject: \n ': 0.15; '"def"': 0.16; '"f"': 0.16; 'confusion': 0.16; 'declaration': 0.16; 'executed,': 0.16; 'executed.': 0.16; 'helping.': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'wrote:': 0.16; 'have:': 0.18; 'laura': 0.18; "shouldn't": 0.18; '>>>': 0.20; '2015': 0.20; 'body,': 0.22; 'latter': 0.22; 'simpler': 0.22; 'trying': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'fri,': 0.27; 'tend': 0.27; 'function': 0.28; 'once.': 0.29; "people's": 0.29; 'that.': 0.30; 'received:be': 0.30; 'says': 0.32; 'point': 0.33; 'steven': 0.33; 'lists': 0.34; 'could': 0.35; 'i.e.': 0.35; 'nov': 0.35; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'aspects': 0.37; 'wrong': 0.38; 'easily': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'easy': 0.60; 'your': 0.60; 'skip:u 10': 0.61; 'stand': 0.67; 'expert': 0.70; 'confusion.': 0.84; "d'aprano:": 0.84; 'disappear': 0.84; 'schreef': 0.84; 'period.': 0.95 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnUHAJ1tVVaGuA9G/2dsb2JhbABehFcBJcAxhg8CggwBAQEBAQGFQAEBBCNIDRELGAICBRYLAgIJAwIBAgFFEwYCAogqrUaMCIQlAQEIAiGBAYVThH6FJ4JOgUQFllWNMoFbhzSPV4NyY4JEgUFxhSwBAQE User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.8.0 In-Reply-To: <564e6a62$0$1620$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99419 Op 20-11-15 om 01:33 schreef Steven D'Aprano: > On Fri, 20 Nov 2015 07:57 am, Marko Rauhamaa wrote: > >> Laura Creighton : >> >>> My experience says that the people who are confused want lists to >>> behave like tuples. period. i.e. they don't want lists to be mutable. >> I think it's simpler than that. When you have: >> >> def f(x=[]): >> y = [] >> >> the first [] is evaluated when "def" is executed, while the latter [] is >> evaluated whenever "f" is executed. It's easy to be confused. > It shouldn't be. The function declaration > > def f(x=[]): > > is executed only once. The function body, conveniently indented to make it > stand out: > > y = [] > > is executed every time you call the function. What exactly is your point? People's confusions don't disappear because you as an expert have a good understanding of what is going on and so are no longer confused. Some aspects in the langauage are easily grasped and other aspects tend to create confusion. I see nothing wrong with people trying to point out what the cause of this confusion could be. You arguing that people shouldn't be confused is not helping. -- Antoon.