def __getitem__(self, key):
for device in self.__devices:<EOL><INDENT>if device.name == key:<EOL><INDENT>return device<EOL><DEDENT><DEDENT>if isinstance(key, int):<EOL><INDENT>return self.__devices[key]<EOL><DEDENT>raise KeyError<EOL>
Return device by name or by index.