Last active
October 6, 2017 17:56
-
-
Save seth10/0cfd56fb396a0894b9067e277c4c6e6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Motor(object): | |
def __init__(self): | |
pass | |
motorA = Motor() | |
motorB = Motor() | |
motorC = Motor() | |
motorD = Motor() | |
Motor.__init__ = lambda: None | |
del Motor | |
class motors(object): | |
A = motorA | |
B = motorB | |
C = motorC | |
D = motorD | |
def __getitem__(self, i): | |
if i == 1 or i == 'A': return self.A | |
if i == 2 or i == 'B': return self.B | |
if i == 3 or i == 'C': return self.C | |
if i == 4 or i == 'D': return self.D | |
raise IndexError("Not a valid motor, try 1-4 or 'A'-'D'") | |
motors = motors() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment