Explanation of list reference

Ned Batchelder ned at nedbatchelder.com
Mon Feb 17 02:43:46 CET 2014


On 2/16/14 5:54 PM, Gregory Ewing wrote:
> Chris Angelico wrote:
>> Because everything in Python is an object, and objects always are
>> handled by their references.
>
> <beginner_thought> So, we have objects... and we have
> references to objects... but everything is an object...
> so does that mean references are objects too?
> </beginner_thought>
>
> This is the kind of trouble you get into when you make
> a statement of the form "everything is an X"[1]. When
> we say "everything is an object", we don't literally
> mean everything, only... well, those things that *are*
> objects. Which doesn't really help the beginner much.
>
> [1] Mathematicians tried this. "Everything is a set!"
> Yeah, right...
>

The correct statement is "all values are objects", or "all data is 
objects".  When people mistakenly say "everything is an object", they 
are implicitly only thinking about data.

That said, "all data is objects" is really mostly useful in contrast to 
other languages where some data is objects and some is not.

I think Ben Finney's point from nearby in this thread is spot on: 
there's a huge difference between a beginning programmer and an 
experienced programmer new to Python.  The latter category is sometimes 
the harder to teach, because you have to undo the things they learned 
about their earlier language X, but which they mistakenly believe to be 
true about all programming languages.

-- 
Ned Batchelder, http://nedbatchelder.com




More information about the Python-list mailing list