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


Groups > comp.lang.python > #99716

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:41:42 +1100
Lines 48
Message-ID <mailman.16.1448851317.14615.python-list@python.org> (permalink)
References <2b4696d5-c9fb-4ca6-92a3-564e47712d59@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de 999rr3nCM7RtJYXqpoVkTgTRfP23LX9LwwG7KYD3gopw==
Cancel-Lock sha1:7yIWpl8Kun7nlM43MPK7sNG3wc0=
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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; "'a'": 0.07; 'assignment': 0.07; 'object;': 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; 'variables': 0.15; 'example)': 0.16; 'integer.': 0.16; 'objects?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:object': 0.16; 'subject:variable': 0.16; 'too?': 0.16; 'variable.': 0.16; "wouldn't": 0.16; 'integer': 0.18; 'variable': 0.18; 'object.': 0.22; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'question': 0.27; 'function': 0.28; 'values': 0.28; 'went': 0.28; 'wright': 0.29; 'objects': 0.29; 'typically': 0.29; 'program,': 0.29; 'everyone': 0.31; 'says': 0.32; 'statement': 0.32; 'point': 0.33; 'surprised': 0.33; 'that,': 0.34; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'names': 0.38; 'anything': 0.38; 'several': 0.38; 'well.': 0.40; 'to:addr:python.org': 0.40; 'called': 0.40; 'some': 0.40; 'term': 0.60; 'your': 0.60; 'watch': 0.62; 'more': 0.63; 'information': 0.63; 'between': 0.65; 'binding': 0.66; 'subject:. ': 0.67; 'skip:\xe2 10': 0.70; '8bit%:40': 0.72; 'covers': 0.72; '_o__)': 0.84; 'received:125': 0.84; 'territory': 0.84; 'serious': 0.97
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:99716

Show key headers only | View raw


fl <rxjwg98@gmail.com> writes:

> I read several parts on line about Python that everything in Python is an 
> object.

Yes, every piece of information that you can get to with your program,
is made available as an object.

The phrase “everything is an object” is significant when newcomers are
surprised that, for example, every function is an object; every type is
an object; every number is an object.

> Then, I read a page it says variables […] I have a question that
> whether variables are objects?

A “variable”, as we use the term in Python, is a *way to access* a
specific object. It is a binding between a name and an object.

> For example,
>
> a=10
>
> 'a' is an integer. Is it an object too?

More specifically, ‘a’ is a name. That name is, at any point in time,
bound to some object. The object to which that name is bound is, in your
example, the integer ‘10’.

A variable is a specific kind of binding: a binding between one name and
one object. An assignment statement (‘a = 10’ in your example) binds a
reference to an object. If that reference is a name, then we call that a
“variable”.

The object is not a variable; objects typically do not know whether any
names are bound to them.

The binding from a name to an object is often called a variable.

Everyone serious about Python should watch Ned Batchelder's presentation
on names and values <URL:http://nedbatchelder.com/text/names.html>,
which covers this territory well.

-- 
 \       “I went to a general store. They wouldn't let me buy anything |
  `\                                     specifically.” —Steven Wright |
_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