Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'languages,': 0.04; 'subject:Python': 0.05; 'assign': 0.07; 'c++,': 0.07; 'variables.': 0.07; 'python': 0.09; '[1,': 0.09; 'bindings': 0.09; 'languages:': 0.09; 'literal': 0.09; 'references.': 0.09; 'unnamed': 0.09; 'aug': 0.13; 'times,': 0.13; 'decent': 0.16; 'did,': 0.16; 'driscoll': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instance:': 0.16; 'means:': 0.16; 'reference).': 0.16; 'subject:Objects': 0.16; 'term.': 0.16; 'variable.': 0.16; 'wrote:': 0.17; 'element': 0.17; 'integer': 0.17; 'pointed': 0.17; 'thu,': 0.17; 'variables': 0.17; '(in': 0.18; 'variable': 0.20; 'sort': 0.21; 'java': 0.21; 'received:209.85.214.174': 0.21; 'implicit': 0.22; 'own.': 0.22; 'example': 0.23; 'references': 0.23; "haven't": 0.23; "i've": 0.23; 'second': 0.24; 'header:In- Reply-To:1': 0.25; 'possibly': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'this?': 0.28; '(possibly': 0.29; 'objects': 0.29; 'class': 0.29; 'to:addr:python-list': 0.33; '(with': 0.33; 'received:google.com': 0.34; 'whatever': 0.35; 'ben': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'programmers': 0.36; 'anything': 0.36; 'ok,': 0.37; 'does': 0.37; 'being': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'things': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'kind': 0.61; 'referred': 0.62; 'more': 0.63; 'charset:windows-1252': 0.65; 'fact,': 0.69; 'discovered': 0.83; 'casting,': 0.84; 'world!"': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Dpsst8fkWrKjnywocBe4mIVihFBldHrVhIBT2K6RqKI=; b=TIFaGlbLB+Khta96a1pC8JQAzRnvkRkt+dOrj4l6gYTMWVobMLclLpQ4EecGy8ArK4 a75BqgIO4Sf0o4XYMc3HeoYpm7sUTWLe2Qd0XpttzMOcI37QnzSToVPVH+HOH2VoiSRY SdaYJ73sUNrJnPhpCDwilaWnXT9y3T1f6AmMHH06OuSTv2TQU1YNK6JCODSH5wXN3dTd 4qjwAqNFz/rbAHmi37wtzddt5V2wyxzXKxl+RMql743LEsUW40qa+3/sZJ6riOgbhaKB BTvfi9U79yccujk0gGI312UXex2QCiOt566tRBad07CRLrcbv8qvNt2RWhBbKtWRdIMd fSbw== MIME-Version: 1.0 In-Reply-To: <5035B64D.2080008@cs.wisc.edu> References: <18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com> <87d32i1ntc.fsf@benfinney.id.au> <5035B64D.2080008@cs.wisc.edu> Date: Thu, 23 Aug 2012 15:33:33 +1000 Subject: Re: Re: Objects in Python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345700016 news.xs4all.nl 6840 [2001:888:2000:d::a6]:37578 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27699 On Thu, Aug 23, 2012 at 2:49 PM, Evan Driscoll wrote= : > On 8/22/2012 18:58, Ben Finney wrote: >> You haven't discovered anything about types; what you have discovered is >> that Python name bindings are not variables. >> >> In fact, Python doesn't have variables =96 not as C or Java programmers >> would understand the term. What it has instead are references to objects >> (with names as one kind of reference). > > OK, I've seen this said a few times, and I have to ask: what do you mean > by this? I consider myself pretty decent at Python and other languages, > and I really don't get it. Simple example that'll work in many languages: x =3D 1; In C, this means: Assign the integer 1 to the variable x (possibly with implicit type casting, eg to floating point). In Java or C++, this means: Assign the integer 1 to the variable x. Ditto, but possibly 'x' is actually a class member etc rather than a simple variable. In Python, this means: Make the name x now refer to the object 1. Whatever x had before is de-referenced by one (in a simple refcounting situation, that may result in the object being destroyed), and the object referred to by the literal 1 is now pointed to by x. Names are just one kind of reference because complex objects can have unnamed references. For instance: foo =3D [1, 2, 3] foo[1] =3D "Hello, world!" The second element of foo just got rebound in exactly the same way x did, but it doesn't have a name of its own. Does that sort things out, or just make things more confusing? ChrisA