Explanation of list reference

Rustom Mody rustompmody at gmail.com
Sat Feb 15 04:14:13 CET 2014


On Saturday, February 15, 2014 8:12:14 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Feb 15, 2014 at 1:34 PM, Rustom Mody wrote:
> > At what level can you explain the following?
> >>>> x = 1234567 * 1234567
> >>>> x
> > 1524155677489L

> Well, for a start, I'd use Python 3, so there's no need to explain why
> some numbers have an L after them :)

Nice point!
And only sharpens what I am saying -- python 3 is probably more confusing than
2 wrt object identity

> > As against
> >>>> x = 2*3
> >>>> 6 is x
> > True
> > "Interning" you will say.
> > Is interning a simple matter for example at the level of questioning of the OP?

> When it's utterly impossible for it to matter in any way, Python is
> allowed to reuse objects.

> I think that's simple enough to explain. There's nothing you can do to
> distinguish one 6 from another, so Python's allowed to have them the
> same.

Simple??

>>> x=1234
>>> y=1234
>>> x is y
False
>>> 1234 is 1234
True
>>> x=123
>>> y=123
>>> x is y
True

-------------
"utterly impossible to matter"...
"nothing you can do to distinguish one 6 from another"

All depend on doing one of these 3 for dealing with object identity
1. Circular definition
2. Delve into implementation
3. Wildly wave the hands

As a teacher Ive done more than my fair share of all especially 3 but if
you have a 4th option Id be interested to know!

Philosophically"to be" called the copula is such a knotty problem that there is 
an entire movement to create a version of English without any form of 
"is,are,be" etc

http://en.wikipedia.org/wiki/E-Prime



More information about the Python-list mailing list