[Tutor] Set and get class members
Phil
phillor9 at gmail.com
Mon Jul 19 01:48:42 EDT 2021
I've read through several tutorial on this but I cannot relate what I'm
reading to the problem.
Say I wanted to set all the LED's status to false, or that of a
particular LED, do I need a set function or can I access the attribute
directly? In either case, what I have done below is not correct.
class Led:
def __init__(self, pos):
self.pos = pos
self.state
def setState(self, s):
self.state = s
self.leds = list()
for i in range(8):
self.leds[i].setState(False)
self.leds.append(Led((50 + (i * 30), 50)))
--
Regards,
Phil
More information about the Tutor
mailing list