Re: strange comparison result with 'is'

2011-10-18 Thread alex23
On Oct 18, 3:53 am, Terry Reedy wrote: > This has come up enough that I opened http://bugs.python.org/issue13203 I really don't get the new Python user obsession with id(). I don't think I've ever used it, in production code or otherwise. -- http://mail.python.org/mailman/listinfo/python-list

Re: strange comparison result with 'is'

2011-10-17 Thread Terry Reedy
On 10/17/2011 5:19 AM, Peter Otten wrote: The getattr() call is just a distraction. Every x.pop attribute access creates a new method object. In the case of x.pop is x.pop False they have to reside in memory simultaneously while in the expression id(x.pop) == id(x.pop) True a list.pop me

Re: strange comparison result with 'is'

2011-10-17 Thread Terry Reedy
On 10/17/2011 4:42 AM, Yingjie Lan wrote: Hi all, This is quite strange when I used the Python shell with IDLE: Nothing to do with IDLE >>> x = [] >> id(getattr(x, 'pop')) == id(x.pop) True >>> getattr(x, 'pop') is x.pop False I suppose since the two things have the same id, the 'is'-

Re: strange comparison result with 'is'

2011-10-17 Thread Peter Otten
Yingjie Lan wrote: > This is quite strange when I used the Python shell with IDLE: > x = [] id(getattr(x, 'pop')) == id(x.pop) > > True getattr(x, 'pop') is x.pop > False > > I suppose since the two things have the same id, the 'is'-test > should give a True value, but I ge

strange comparison result with 'is'

2011-10-17 Thread Yingjie Lan
Hi all,  This is quite strange when I used the Python shell with IDLE: >>> x = [] >>> id(getattr(x, 'pop')) == id(x.pop) True >>> getattr(x, 'pop') is x.pop False >>>  I suppose since the two things have the same id, the 'is'-test  should give a True value, but I get a False value.  Any partic