Whatif I dont make "self.yadayada" definition in __init__, what happens to the args?


If i dont make self.variable assignments in the init function of a class, what happens to the arguments I passed to that class? How they are treated?

I am too much with those questions I know, but I really wonder.. thank you..


well, one way to find out:

class Car(object):
    condition = "new"
    def display_car(self):
        return "This is a %s %s with %s MPG and a %s battery." % (self.color, self.model, str(self.mpg), self.battery_type)
    def drive_car(self):
        self.condition = "used"

my_car = Car("my_car", "Tesla", "silver", 88)

it will throw an error, given it doesn't now how to handle the arguments you supply at creating class instance


İ see.. its kind of hanging in the air situation for the args.. thank you:)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.