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: What is a function parameter =[] for? Date: Tue, 24 Nov 2015 21:17:10 +0200 Organization: A noiseless patient Spider Lines: 39 Message-ID: <8737vv8ax5.fsf@elektro.pacujo.net> References: <56544BAB.9020709@rece.vub.ac.be> <874mgbpnb5.fsf@elektro.pacujo.net> <486929d1-4caa-403c-89e6-c45d7b447f98@googlegroups.com> <3589d016-f9ba-4217-83ea-4041ac085230@googlegroups.com> <51dc19ec-9ea0-4b37-bd66-6ebdacc83d87@googlegroups.com> <877fl78dvh.fsf@elektro.pacujo.net> <5654ad75$0$1583$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="22446"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ynwKmn1euvPBl46Yk9bQQ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:WIftrEPsnan6llRBP0z/k72h+2o= sha1:I0ZuCZM7VHG0MbXzUYUf3IG8NLg= Xref: csiph.com comp.lang.python:99390 Steven D'Aprano : > On Wed, 25 Nov 2015 05:13 am, Marko Rauhamaa wrote: >> I would prefer this wording: >> >> Objects whose inner state can change are said to be mutable > > I see your point, but "inner state" might not be related to the > object's externally visible value. The inner state is indeed inaccessible. We cannot determine immutability by testing, but we *can* determine mutability (if we're lucky). > For example, dicts have an inner state which can vary, even when their value > remains the same: > > # using Python 3.3 > > py> d = {-1: "a", -2: "b"} > py> e = {-2: "b", -1: "a"} > py> d == e > True > py> print(d, e) > {-2: 'b', -1: 'a'} {-1: 'a', -2: 'b'} > > The two dicts have the same value, but their inner state is slightly > different, which is why they print in different order. I'd say an object o is mutable (at least) if it has got a method m such that: before = o.m() # any intervening code that does not reassign o after = o.m() before == after => False Marko