Fix sintax error for python3.
Fix "local variable 'template_string' referenced before assignment"