def format_colors(text):
 def replace_color(m):
  '\n        Callback function, to replace a colour tag with its content and a\n        suitable escape sequence to change colour.\n        '
  return ('%s%s%s' % (Colors[m.group(1)], m.group(2), Colors['end']))
 text = re.sub('\\[color\\s*([a-z]+)\\](.*?)\\[\\/color\\]', replace_color, text)
 return text

def format_colors ( text ) : def replace_color ( m ) : return ( '%s%s%s' % ( Colors [ m . group ( 1 ) ] , m . group ( 2 ) , Colors [ 'end' ] ) ) text = re . sub ( '\\[color\\s*([a-z]+)\\](.*?)\\[\\/color\\]' , replace_color , text ) return text
inserts *nix colour sequences into a string .