import copy
class Text(object):
def __init__(self, current_text=""):
self.current_text = current_text
def getx(self):
return self.current_text
def write(self,newtext):
if '[' in self. current_text:
number=self.current_text.rindex('[')
self.current_text= self.current_text[0:number]+newtext+self.current_text[number::]
else:
self.current_text=self.current_text+newtext
return self.current_text
def set_font(self, font):
self.current_text="["+font+"]"+self.current_text+"["+font+"]"
return self.current_text
def show(self):
return self.current_text
def restore(self, version):
self.current_text = version
return self.current_text
def __str__(self):
return str(self.current_text)
class SavedText(object):
def __init__(self, saved=[]):
self.saved =[]
def getu(self):
return self.saved
def save_text(self, document):
Originator.set(copy.copy(document))
self.saved.append(Originator.save_to_memento())
def get_version(self, number):
return self.saved[number]
def __str__(self):
return str(self.saved)
class Memento(object):
def __init__(self, state):
self._state = state
def get_saved_state(self):
return self._state
def __str__(self):
return '"' +str(self._state) +'"'
class Originator(object):
_state = ""
def set(self, state):
self._state = state
def save_to_memento(self):
return Memento(self._state)
def restore_from_memento(self, memento):
self._state = memento.get_saved_state()
Originator=Originator()
checkio says that there is a TypeError: <class 'dict'> is wrong data type , i dont understand what i did wrong
Created at: 2019/03/12 05:28; Updated at: 2019/03/14 05:07
The question is resolved.