Self is created when the instance of a class is created. So, there is no self outside the __init__ method. You can remove self. part or do it like this. Try it. I am not really sure of what I am talking about. This is how I understand all that classy classiness
In the other side are the class objects. You just define them as regular objects inside the class definition
def __init__(self): self.selected_option = 0 self.options = [ 'On', 'Off', ] self.actions = [ self.handle_On, self.handle_Off, ]__init__ method is executed when an instance of a class is created. Self is a reference to that instance. self.object is called instance object and defining one outside of the __init__ method obviously is causing this error.
In the other side are the class objects. You just define them as regular objects inside the class definition
class Foo: def __init__(self, obj_1, obj_2, obj_3): self.one = obj_1 # instance attribute self.two = obj_2 # instance attribute three = obj_3 # class attributeBecause class objects are owned by the class they are shared between all instances of that class. While the instance objects are different for every instance of that class.