   Simulating a command line in a pygame app
  I have the beginning of an implementation of a command line that will process the 'a', 'b', and backspace key presses properly while processing every other non-modifier key as a space.  It also displays an underscore as the blinking cursor.  My main concern at this stage is if there's any serious risk of memory/gc problems or if my methods are too complicated compared to a simpler way to make a command line in a pygame application.The code below assumes that a font object has been created and will render the generated text to the screen every frame.  Also, something with the forums seems to be leaving out plus characters, so I'll be using 'plus' to refer to string concatenations.self.st = ['_']#array of characters that will be concatenated to a stringself.stri = ' '#the string that will be rendered to a font surface#every half of a second, make the cursor appear at the end of the string and blinkdef cursblink(self):tick = time.get_ticks()if tick%1000 < 500:self.st.pop()self.st.append('_')else:self.st.pop()self.st.append(' ')#called if the KEYDOWN event is passed in the main loop with the event as argument 'key'.  this function appends characters to a list based on what key was pressed.def textparse(self, key):if key == K_a:self.st.pop()self.st.append('a')self.st.append('_')elif key == K_b:self.st.pop()self.st.append('b')self.st.append('_')elif key == K_BACKSPACE:if self.st.__len__() > 1:self.st.pop()self.st.pop()self.st.append('_')else:passelse:self.st.pop()self.st.append(' ')self.st.append(' ')slen = self.st.__len__()iter = 0self.stri = ' 'while iter < slen:self.stri = self.stri 'plus' self.st[iter]iter = iter 'plus' 1#called at the end of textparse() and at least once a frame to process the array of characters into a string by using the listdef textparse2(self):self.cursblink()slen = self.st.__len__()iter = 0self.stri = ' 'while iter < slen:self.stri = self.stri 'plus' self.st[iter]iter = iter 'plus' 1