Skip to content

Instantly share code, notes, and snippets.

@seth10
Last active October 6, 2017 17:56
Show Gist options
  • Save seth10/0cfd56fb396a0894b9067e277c4c6e6e to your computer and use it in GitHub Desktop.
Save seth10/0cfd56fb396a0894b9067e277c4c6e6e to your computer and use it in GitHub Desktop.
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