Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
class SetAndGet(list) solution in Clear category for Voice TV Control by flpo
class VoiceCommand(object):
def __init__(self, channels):
self.channel = channels[0]
class SetAndGet(list):
def __getitem__(self_list, item):
self.channel = super(SetAndGet, self_list).__getitem__(item)
return self.channel
@property
def current(self_list):
return self_list.index(self.channel)
self.channels = SetAndGet(channels)
def first_channel(self):
return self.channels[0]
def last_channel(self):
return self.channels[-1]
def turn_channel(self, i):
return self.channels[i - 1]
def next_channel(self):
return self.channels[(self.channels.current+1) % len(self.channels)]
def previous_channel(self):
return self.channels[(self.channels.current - 1) % len(self.channels)]
def current_channel(self):
return self.channel
def is_exist(self, c):
return ('No', 'Yes')[type(c) is str and c in self.channels or 0 < c <= len(self.channels)]
June 16, 2018
Comments: