Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99717

Re: variable vs. object

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: variable vs. object
Date Mon, 30 Nov 2015 13:45:55 +1100
Lines 35
Message-ID <mailman.17.1448851821.14615.python-list@python.org> (permalink)
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 <python-python-list@m.gmane.org>
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 <bignose+hates-spam@benfinney.id.au>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99717

Show key headers only | View raw


André Roberge <andre.roberge@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

variable vs. object fl <rxjwg98@gmail.com> - 2015-11-29 18:06 -0800
  Re: variable vs. object Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-29 21:16 -0500
  Re: variable vs. object André Roberge <andre.roberge@gmail.com> - 2015-11-29 18:24 -0800
    Re: variable vs. object Ben Finney <ben+python@benfinney.id.au> - 2015-11-30 13:45 +1100
  Re: variable vs. object Ben Finney <ben+python@benfinney.id.au> - 2015-11-30 13:41 +1100
  Re: variable vs. object Marko Rauhamaa <marko@pacujo.net> - 2015-11-30 07:28 +0200
  Re: variable vs. object Nagy László Zsolt <gandalf@shopzeus.com> - 2015-11-30 09:09 +0100
  Re: variable vs. object Chris Angelico <rosuav@gmail.com> - 2015-11-30 19:19 +1100

csiph-web