I am currently writing some code and have a main class (called "startup") and a secondary class which activates something on being called (called "Ringer"). All I want to do is initiate the Ringer class with Ringer()
, and then do some code and when conditions are met, call Ringer.__on()
. Same goes for Ringer.__off()
.
Seems like I am doing something very simple wrong.
Below is some code of what I am trying to achieve... I am getting an Attribute Error
with this.
class Ringer:
def __init__(self):
print('__init__')
def __on(self):
print('turn on')
def __off(self):
print('turn off')
class start:
def __init__(self):
Ringer() #init something
Ringer.__on() #call ONLY the on function
Ringer.__off() #call ONLY the off function
if __name__ == '__main__':
start()
The output of the above code should be
__init__
turn on
turn off