Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Date: Thu, 19 Nov 2015 22:57:10 +0200 Organization: A noiseless patient Spider Lines: 15 Message-ID: <87d1v5emhl.fsf@elektro.pacujo.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="24257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+8gqQjnnaNaSMonp9q4QN" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:IGwtY23QrtqV7IEjzPiuQPcf8fA= sha1:Vth2MAhikyKeP3YAwTHjT3LGRC4= Xref: csiph.com comp.lang.python:99096 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. Marko