Class equivalence?

Pedro B. Gomes Costa pbeck at ciberbit.pt
Thu Dec 6 15:01:30 EST 2001


Hi!

"is" is used to check for object identity (if they reference the same
physical memory location).

>>>class Flower: pass
>>>class Daisy(Flower): pass

>>>aDaisyInstance = Daisy()
>>>anotheraDaisyInstance = aDaisyInstance
>>>anotheraDaisyInstance is aDaisyInstance
1

Comnparing with Java (btw, I have all your books...):
String str1, str2;

str1 == str2   - > str1 is str2 (in python)
str1.equals(str2) -> str1 == str2 (in python)

Hope it helps

Pedro Costa
----- Original Message -----
From: "Bruce Eckel" <Bruce at EckelObjects.com>
To: <python-list at python.org>
Cc: <tim.one at home.com>; <pnorvig at google.com>
Sent: Thursday, December 06, 2001 7:49 PM
Subject: Class equivalence?


> >>> class Flower: pass
> >>> class Daisy(Flower): pass
> >>> Daisy is Flower
> 0
>
> What am I missing here?
>
> Most current information can be found at:
> http://www.mindview.net/Etc/notes.html
> ===================
> Bruce Eckel    http://www.BruceEckel.com
> Contains free electronic books: "Thinking in Java 2e" & "Thinking
> in C++ 2e"
> Please subscribe to my free newsletter -- just send any email to:
> join-eckel-oo-programming at earth.lyris.net
> My schedule can be found at:
> http://www.mindview.net/Calendar
> ===================
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list