python - what went wrong with my get and set properties? -
please need help. code pycharm , keeps showing me unresolved reference 'model'. parameter 'model' value not used , getter signature should (self). please how around this.
class productobject: def __init__(self, product, brand, car, model, year): self.product = product self.brand = brand self.car = car self.model = model self.year = year def set_product(self, product): self.product = product.capitalize() def get_product(self): return self.product product = property(get_product, set_product) def set_brand(self, brand): self.brand = brand.title() def get_brand(self): return self.brand brand = property(get_brand, set_brand) def set_car(self, car): self.car = car.title() def get_car(self): return self.car car = property(get_car, set_car) def set_model(self): self.model = model.title() def get_model(self, model): return self.model model = property(get_model, set_model) def set_year(self): self.year = year.int() def get_year(self, year): return self.year year = property(get_year, set_year)
you need change parameters of methods. method needs self , set method need self , model parameter.
def set_model(self, model): self.model = model.title() def get_model(self): return self.model
edit inheriting class:
class yoursubclass(productobject): #code of subclass inherit productobject class
module: if want create module should check module structure nothing more classes init.py file. can import classes normal import statements. here link info init.py file: init.py structure
Comments
Post a Comment