Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: variable vs. object Date: Mon, 30 Nov 2015 13:45:55 +1100 Lines: 35 Message-ID: References: <2b4696d5-c9fb-4ca6-92a3-564e47712d59@googlegroups.com> <2c516888-de4f-4dd7-b1c0-fe56bb03f754@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de ljysjBeMWGAUBuJL7Fn0eA/vtGHGnhBfcLJnFg7jqZjA== Cancel-Lock: sha1:sIsmJrBbIFN4iOPEL1NB6UmctgI= 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; 'python,': 0.02; 'assignment': 0.07; 'imply': 0.07; '"a"': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; '"="': 0.16; '*never*': 0.16; 'confusion': 0.16; 'integer.': 0.16; 'objects;': 0.16; 'rather,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'side.': 0.16; 'subject:object': 0.16; 'subject:variable': 0.16; 'refers': 0.18; 'affects': 0.22; 'assign': 0.22; 'object.': 0.22; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X -Complaints-To:1': 0.26; 'object,': 0.27; 'position.': 0.30; "i'd": 0.31; 'point': 0.33; 'false': 0.35; 'knowledge': 0.35; 'assigned': 0.36; 'totally': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:org': 0.37; 'names': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'care': 0.60; 'information,': 0.61; 'avoid': 0.61; 'subject:. ': 0.67; 'sir,': 0.79; 'hand': 0.82; '_o__)': 0.84; 'object:': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) 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:99717 André Roberge writes: > In Python, a "variable" is a name given to an object. In Python, the > "=" sign is used to assign a name to an object: the name is on the > left-hand side, and the object is on the right hand side. Multiple > names can be assigned to the same object. Take care with the directionality of those statements. In Python we don't give the name *to* the object, which would imply that the object “has” that name in some sense. The object is totally unaffected, and assignment does not give the object any knowledge about that name. We also don't assign names *to* objects; if anything, we assign the object to the name. It is the name that “has” the object. Or perhaps less confusingly, the name is *bound to* the object. It is frequently a point of confusion that assignment *never* affects the object, so it's best to avoid giving that false impression. > In the example you gave, "a" is a name given to the object "10" which > is an integer. Rather, I'd prefer to say that ‘a’ now refers to the object ‘10’. The object ‘10’ was not “given” anything. -- \ “When I get new information, I change my position. What, sir, | `\ do you do with new information?” —John Maynard Keynes | _o__) | Ben Finney