A question on modification of a list via a function invocation

breamoreboy at gmail.com breamoreboy at gmail.com
Wed Sep 6 10:36:34 EDT 2017


On Wednesday, September 6, 2017 at 1:12:22 PM UTC+1, Rustom Mody wrote:
> On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote:
> > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote:
> > 
> > 
> > > Can you explain what "id" and "is" without talking of memory?
> > 
> > Yes.
> > 
> > id() returns an abstract ID number which is guaranteed to be an integer, and
> > guaranteed to be distinct for all objects which exist at the same time. When an
> > object ceases to exist, its ID number may be re-used.
> > 
> > `is` compares the two operands for identity. If the two operands are the same
> > object, `is` returns True, if they are distinct objects, `is` returns False.
> 
> >>> a = (1,2)
> >>> b = (1,2)
> >>> a is b
> False
> >>> x = 1
> >>> y = 1
> >>> x is y
> True
> 
> a seems to be as 'same' to b as x is to y
> Python seems to think otherwise
> 
> Evidently your ‘same’ is not the same as mine??
> 

This shows your complete ignorance of Python.  One would often suggest putting the shovel down, but it is far too late for that.

Kindest regards.

Mark Lawrence.



More information about the Python-list mailing list