what went wrong with my get and set properties?

Please I need help. I code with PyCharm and it keeps showing me unresolved reference 'model'. Parameter 'model' value is not used and getter signature should be (self). Please how do I get 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)

Upvotes: 1

Views: 2292

Answers (1)

Bulva
Bulva

Reputation: 1248

You need change parameters of methods. Get method needs only self and set method need self and model as parameter.

def set_model(self, model):
    self.model = model.title()

def get_model(self):
    return self.model

EDIT Inheriting from your class:

class YourSubclass(ProductObject):
    #code of your subclass which inherit from ProductObject class

Module: if you want create module you should check this Module structure Is it nothing more than classes with init.py file. You can then import classes with normal import statements. Here is another link with info about init.py file: Init.py structure

Upvotes: 1

Related Questions