Explaining names vs variables in Python

Rustom Mody rustompmody at gmail.com
Wed Mar 2 10:08:19 EST 2016


On Wednesday, March 2, 2016 at 7:42:09 PM UTC+5:30, Marko Rauhamaa wrote:
> Chris Angelico :
> 
> > On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa  wrote:
> >> Chris Angelico :
> >>
> >>> Python defines that every object has an identity, which can be
> >>> represented as an integer. Since this is an intrinsic part of the
> >>> object, no two distinct objects can truly have identical
> >>> characteristics. Python's objects are like rifles - there are many
> >>> like it, but this one is mine.
> >>
> >> How can you be sure Python isn't returning the same id value for two
> >> distinct objects?
> >
> > The same way I can be sure about anything else in Python. It's a
> > language guarantee.
> 
> Actually, my question is (intentionally) nonsensical.
> 
> The sameness or distinctness of two objects is not directly defined in
> Python. The definition is simply:
> 
>    Two objects X and Y are called identical if
> 
>        X is Y
> 
>    evaluates to a true value.
> 
> Additionally, we have:
> 
>    If objects X and Y are identical, it is guaranteed that
> 
>       id(X) == id(Y)
> 
>    evaluates to a true value.
> 
> Even more strongly, we have:
> 
>    For any objects X and Y,
> 
>       id(X) == id(Y) if X is Y else id(X) != id(Y)
> 
>    evaluates to a true value.
> 
> What is missing is the rules that are obeyed by the "is" operator.

is is not is
is is was
[fermionic or bosonic?]



More information about the Python-list mailing list