[Tutor] Identifying objects

David Ascher da@ski.org
Mon, 27 Sep 1999 09:14:42 -0700 (Pacific Daylight Time)


On Mon, 27 Sep 1999, K P wrote:

> How would I detect object recursing(that may not be the real term 
> for it)? For example, I have:
> 
> class myObject():
>    def myFunct(param)
> 
> tempObj = myObject()
> 
> tempObj.myFunct(tempObj)
> 
> How would tempObj.myFunct determine that its own object was 
> passed to it?

if param is self:
  ...

Note that 'is' tests reference identity, while == tests value equality.

--david