Explanation of list reference
rustompmody at gmail.com
Sat Feb 15 03:34:39 CET 2014
On Saturday, February 15, 2014 7:38:39 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Feb 15, 2014 at 12:55 PM, Rustom Mody wrote:
> > On Saturday, February 15, 2014 6:27:33 AM UTC+5:30, Chris Angelico wrote:
> >> Can you give an example of an ambiguous case? Fundamentally, the 'is'
> >> operator tells you whether its two operands are exactly the same
> >> object, nothing more and nothing less
> > Fundamentally your definition above is circular: In effect
> > the python expr "a is b" is the same as a is b.
> It's not circular, it's stating the definition of the operator. And
> since the definition is so simple, it's impossible - at that level -
> for it to be ambiguous. It's possible for equality to be ambiguous, if
> you have two types which define __eq__:
At what level can you explain the following?
>>> x = 1234567 * 1234567
>>> y = 1234567 * 1234567
>>> x is y
>>> 1524155677489 == x
>>> 1524155677489 is x
>>> x = 2*3
>>> y= 2*3
>>> x == y
>>> x is y
>>> 6 is x
"Interning" you will say.
Is interning a simple matter for example at the level of questioning of the OP?
More information about the Python-list