class client():
def __init__(self,identitate,nume,cnp,filme_inchiriate,inchirieri):
self.__identitate=identitate
self.__nume=nume
self.__cnp=cnp
self.__filme_inchiriate=filme_inchiriate
self.__inchirieri=inchirieri
def get_identitate(self):
return self.__identitate
def get_nume(self):
return self.__nume
def get_cnp(self):
return self.__cnp
def get_filme_inchiriate(self):
return self.__filme_inchiriate
def get_inchirieri(self):
return self.__inchirieri
def set_identitate(self, value):
self.__identitate = value
def set_nume(self, value):
self.__nume = value
def set_cnp(self, value):
self.__cnp = value
def set_filme_inchiriate(self, value):
self.__filme_inchiriate = value
def set_inchirieri(self, value):
self.__inchirieri = value
def del_identitate(self):
del self.__identitate
def del_nume(self):
del self.__nume
def del_cnp(self):
del self.__cnp
def del_filme_inchiriate(self):
del self.__filme_inchiriate
def del_inchirieri(self):
del self.__inchirieri
identitate = property(get_identitate, set_identitate, del_identitate, "identitate's docstring")
nume = property(get_nume, set_nume, del_nume, "nume's docstring")
cnp = property(get_cnp, set_cnp, del_cnp, "cnp's docstring")
filme_inchiriate = property(get_filme_inchiriate, set_filme_inchiriate, del_filme_inchiriate, "filme_inchiriate's docstring")
inchirieri = property(get_inchirieri, set_inchirieri, del_inchirieri, "inchirieri's docstring")
def __str__(self):
return "ID: " + str(self.get_identitate()) + " Nume: " + str(self.get_nume()) + " CNP: "+ str(self.get_cnp())
from entities import *
class validator_client():
def validate_client(self,client):
erori=[]
if client.get_identitate=="":
erori.append("Nu ati introdus ID!")
if client.get_nume=="":
erori.append("Nu ati indorus nume!")
if len(erori)>0:
raise ValidatorException(erori)
def haha(self,client):
if client.get_identitate()=="1":
print "hahahah"
class ValidatorException(Exception):
def __init__(self,erori):
self.__erori=erori
def get_erori(self):
return self.__erori
def __str__(self):
return self.erori
erori = property(get_erori, None, None, None)
client1=client("",2,3,4,5)
validare=validator_client()
try:
validare.validate_client(client1)
except:
ValidatorException
print (ValidatorException)
client()
是一个有 5 个属性的类,其中第一个是 id,它有一个 getter 和 setter,所以这个类没有问题,但是为什么在我运行它时没有打印任何错误?