Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99716
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: variable vs. object |
| Date | 2015-11-30 13:41 +1100 |
| Message-ID | <mailman.16.1448851317.14615.python-list@python.org> (permalink) |
| References | <2b4696d5-c9fb-4ca6-92a3-564e47712d59@googlegroups.com> |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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