Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assignment': 0.07; 'modify': 0.07; 'assigning': 0.09; 'facts': 0.09; 'python:': 0.09; 'python': 0.11; 'language,': 0.12; 'wrote': 0.14; 'changes': 0.15; '"a"': 0.16; '###': 0.16; 'bound.': 0.16; 'garbage': 0.16; 'objects.': 0.16; 'points:': 0.16; 'so!': 0.16; 'sorts': 0.16; 'unbound,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'aug': 0.22; 'previously': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'this:': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'change,': 0.30; '(unless': 0.31; '-0700,': 0.31; "d'aprano": 0.31; 'object.': 0.31; 'piece': 0.31; 'prints': 0.31; 'steven': 0.31; 'fri,': 0.33; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'name': 0.63; 'happen': 0.63; 'between': 0.67; 'subject:skip:E 10': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=iFhSN5AQhESQhOHmKjeZyOfcS2dhCXF1N/kWy8fwA3U=; b=XPnIslOpC29srODe35KQjwPgC3/pq4EL7D+NxiH3UtQc2CSkw4J76+niV8zIZcSk5k I/VSyeN4/di2BsUyeZPAIrUmyztJwhmSgEIKHl//joWuznSuRrBse+Az19yy6BW43/Ic QSbIdo8VJ8RiMeQSSXoykVGQ8TXN6oq/mH4qLdIcwvAoTc4US0DFLmgj2phjg540ZfXF FDxAVvy+8zgE03/dBnZh7Grt4HncTi31XyfiuFv8IFnvjJh8uraZXeYIrya6qZsHrDQz 7r9cP9pvOMezqvcfx7VRPLhQbNvTs5VTlmiKGRdgasA1IfcZZJ91BGcIN0KROsKs9DQt xb6A== X-Received: by 10.49.25.102 with SMTP id b6mr406039qeg.91.1377952916500; Sat, 31 Aug 2013 05:41:56 -0700 (PDT) Sender: Ned Batchelder Date: Sat, 31 Aug 2013 08:41:54 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Encapsulation unpythonic? References: <8255dfbd-a2a1-4ab7-b900-ee19faa459f2@googlegroups.com> <8c7c4854-70e1-46e7-a3ff-a3206c4c5c27@googlegroups.com> <5221567b$0$6599$c3e8da3$5496439d@news.astraweb.com> <5221d7ab$0$6599$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <5221d7ab$0$6599$c3e8da3$5496439d@news.astraweb.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 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377952926 news.xs4all.nl 15972 [2001:888:2000:d::a6]:55045 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53348 On 8/31/13 7:46 AM, Steven D'Aprano wrote: > On Fri, 30 Aug 2013 23:07:47 -0700, Fabrice Pombet wrote: > >> well, look at that: >> >> a=(1,2) >> a=2+3 ->a is an object and I have changed its type and value from >> outside. > Incorrect. You have not changed the type or value of any object. "a" is > not an object, it is a *name*, and while you can change the object bound > to the name, the objects remain unchanged. > > When you do this: > > x = 23 > x = 42 > > the *object* 23 does not change, only the name binding changes. To do > otherwise would cause all sorts of surprises: > > # THIS DOES NOT HAPPEN IN PYTHON > # or any other language, as far as I am aware > x = 23 > y = x # y now has the value 23 > x = 42 # change the value of the object ### NOT SO! ### > print y > => prints 42 > > Name binding (assignment) does not change objects. It changes the link > between a name and the object, but the object remains untouched (unless > it is unbound, and garbage collected). Assignment is not mutation. > Assigning to a name does not modify the object that was previously bound. > I wrote a piece about names and values that might help clarify these points: Facts and Myths about Names and Values in Python: http://nedbatchelder.com/text/names.html --Ned.