[ZPT] Trailing newline added by TALInterpreter.__call__()

Evan Simpson evan at 4-am.com
Wed Jun 9 12:19:13 EDT 2004


Fred Drake wrote:
> The TALInterpreter class is very careful to add a trailing newline at the end 
> of a rendering if there isn't one already present.  This vaguely feels like 
> something that was done to make the user experiance nicer for someone working 
> with the templates in an editor, but there's no comment explaining it in the 
> code.

Nope, it was done because of this:

 >>> exec('''if 1:\n  print 1''')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<string>", line 2
     print 1
          ^
SyntaxError: invalid syntax
 >>> exec('''if 1:\n  print 1\n''')
1

This was fixed in Python 2.3, apparently, so the code can probably be 
removed.

Cheers,

Evan @ 4-am



More information about the ZPT mailing list