Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> class A(object):
- def __init__(self):
- print "The self.__class__ attribute is:", self.__class__
- def getClassAddress(self):
- RETURN self.__class__
- >>> a = A()
- The self.__class__ attribute IS: <class '__main__.A'>
- >>> A().getClassAddress() == A # we test IF the self.__class__ IS equal TO the A IN the global scope; i.e the actual class name
- The self.__class__ attribute IS: <class '__main__.A'>
- TRUE
- >>> A().getClassAddress() IS A # This TIME we ensure that they are the same object, AND NOT a copy; i.e same memory address
- The self.__class__ attribute IS: <class '__main__.A'>
- TRUE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement