[Zope] strange 'print' behavior in Python Scripts

Christopher N. Deckard cnd@ecn.purdue.edu
Fri, 29 Jun 2001 14:12:27 -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

Hmm, this was not the answer I was looking for.  Are there any
thoughts on fixing this in the future?  I've fun into it many times
now and couldn't figure out what was going on.  It is especially bad
when printing a textarea for a form.  Everything comes out indented
a space.  

I'll just go line by line for now.  Thanks for the answer.

-Chris