Re: Terminology: “reference” versus “pointer”

Chris Angelico rosuav at gmail.com
Sat Sep 12 02:31:16 EDT 2015


On Sat, Sep 12, 2015 at 4:26 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> If you do agree with those, some corollaries follow:
>
> * Container types do not contain objects.
>
>   It is a useful analogy to say the objects are “in” the container; but
>   that would imply they are not simultaneously in any other container.
>   That's not true, so it's a flawed (though very useful) analogy.

It's so useful that we have an operator called "in", implemented using
a magic method "__contains__", to test exactly that concept. As long
as you understand that containment here really means something more
like "is accessible from", it's correct. Flawed in a minor way, but so
extremely convenient that it's not worth going for complete technical
correctness.

ChrisA



More information about the Python-list mailing list