Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: Marco Buttu Newsgroups: comp.lang.python Subject: Re: Encapsulation unpythonic? Date: Sat, 31 Aug 2013 08:49:45 +0200 Organization: Aioe.org NNTP Server Lines: 34 Message-ID: <52219209.5030806@gmail.com> References: <8255dfbd-a2a1-4ab7-b900-ee19faa459f2@googlegroups.com> <8c7c4854-70e1-46e7-a3ff-a3206c4c5c27@googlegroups.com> <5221567b$0$6599$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: ptoLr+famN1ev3+5NOt4rQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.python:53324 On 08/31/2013 08:07 AM, 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. No, `a` is not an object, so you did not change the type of any object. `a` is just a name (a label), that initially refers to the tuple (1, 2): >>> a = (1, 2) >>> id(a) 140377464514968 ad after, to another object, of type int: >>> a = 2 + 3 >>> id(a) 8752608 The bytecode: >>> dis.dis('a = (1, 2); a = 2 + 3;') 1 0 LOAD_CONST 4 ((1, 2)) 3 STORE_NAME 0 (a) 6 LOAD_CONST 5 (5) 9 STORE_NAME 0 (a) 12 LOAD_CONST 3 (None) 15 RETURN_VALUE Regards, M. -- Marco Buttu