Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99717
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: variable vs. object |
| Date | 2015-11-30 13:45 +1100 |
| 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> |
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 | 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