I initially planned to add the always off border, but decided in the end not to, and instead to avoid having to bounds check by just trying to reference outside the bounds and catching IndexError. This, failed because Python is perfectly happy with an index of [-1] in a list or string so I had to add a bounds check for the index < 0 case.
I decided to do part 2 by subclassing my part 1 answer, so the additional code was just:
class LightArray2(LightArray):
def __init__(self, str):
LightArray.__init__(self, str)
self.lightCorners()
def lightCorners(self):
self.elements[0]= '#'+self.elements[0][1:-1]+'#'
self.elements[-1]= '#'+self.elements[-1][1:-1]+'#'
def evolve(self, steps):
for i in range(steps):
LightArray.evolve(self, 1)
self.lightCorners()
return self
Which of course makes use of the [-1] index behaviour that I fell foul of earlier.