object.__new__
__init__
class ClassA(object):
def __init__(self, name, age, address):
self.name = name
self.age = age
self.address = address
def toString(self):
return 'Name: %s/r/n Age: %d/r/n Address: %s/r/n' % (self.name, self.age, self.address)
def __eq__(self, other):
if type(other) != type(self):
return False
try:
return self.name == other.name and self.age == other.age and self.address == other.address
except:
return False
def __ne__(self, other):
return not self.__eq__(other)
obj = object.__new__(ClassA)
obj.__init__("JinLidong", 24, "Hangzhou China")
print obj.toString()
print type(obj)
print '/n', '-' * 50, '/n'
obj1 = ClassA("JinLidong", 24, "Hangzhou China")
print obj1.toString()
print type(obj1)
print '/n', '-' * 50, '/n'
print obj1 == obj