jonni83 / smartgarage

1 stars 1 forks source link

storing constants as instance varibles. #2

Closed riverajo closed 10 years ago

riverajo commented 10 years ago

Your Relay class is storing class constants GPIO.LOW and GPIO.HIGH as instanstance varibles. You really don't need to store them as those constants are availible to you through GPIO. If you do want to rename them to on/off, they should be class static. i.e:

class Relay(Component):

    LIGHTON = GPIO.LOW
    LIGHTOFF = GPIO.HIGH

    def __init__(self, red=24, yellow=23, green=18, mode=GPIO.BCM):
    ...

you then access them like Relay.LIGHTON

jonni83 commented 10 years ago

i'm only storing them that way to improve readability. for me, the mapping is counter-intuitive, but that's how the relays work.