[Zope] strange 'print' behavior in Python Scripts
Evan Simpson
evan@4-am.com
Fri, 29 Jun 2001 11:38:42 -0500
From: "Christopher N. Deckard" <cnd@ecn.purdue.edu>
> Clarification, this happens when using triple quotes
>
> print '''
> foo
> bar
> '''
>
> Actually prints:
> foo
> bar
Ah, I knew this would bite somebody someday, but you're the first to
mention it. When a Script is compiled, it is actually converted into a
function by prefixing it with a "def f(params..." line. If the body
isn't indented, it won't compile, so it indents it one space. You can
get around this by manually indenting. In other words:
## Script (Python) "indented"
print '''
foo
bar
'''
return printed
Cheers,
Evan @ digicool