def lastColorizedLine(source):
 if (not isinstance(source, bytes)):
  source = source.encode('utf-8')
 w = VT102Writer()
 p = TokenPrinter(w.write).printtoken
 s = BytesIO(source)
 for token in _tokenize(s.readline):
  (tokenType, string, start, end, line) = token
  p(tokenType, string, start, end, line)
 line = str(w).encode('utf-8')
 return line

def lastColorizedLine ( source ) : if ( not isinstance ( source , bytes ) ) : source = source . encode ( 'utf-8' ) w = VT102Writer ( ) p = TokenPrinter ( w . write ) . printtoken s = BytesIO ( source ) for token in _tokenize ( s . readline ) : ( tokenType , string , start , end , line ) = token p ( tokenType , string , start , end , line ) line = str ( w ) . encode ( 'utf-8' ) return line
tokenize and colorize the given python source .