[Zope] Re: strange 'print' behavior in Python Scripts

Lewis, Pat H. Pat_Lewis@Invesco.com
Fri, 29 Jun 2001 13:16:03 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C100BF.2CD5FEE0
Content-Type: text/plain;
	charset="iso-8859-1"

I have no idea why Python Scripts is acting this way.  Can you generate your
xml without
using triple quotes?

print 'foo\nbar'

or 

print '%s\n%s' % ('foo', 'bar')

--
Patrick Lewis

"Christopher N. Deckard" wrote:
> Clarification, this happens when using triple quotes
> 
> print ''' 
> foo 
> bar 
> ''' 
>
> Actually prints: 
> foo 
> bar 
>
>-Chris 
>
> >"Christopher N. Deckard" wrote: 
> > 
> > I'm running into problems because Zope is printing a space (" ") at the 
> > beginning of each line when 'print'ing from a Python Script. I'm trying 
> > to print out XML to a Java Applet and the Applet isn't smart enough to 
> > take this into account. Bad parser, but Zope shouldn't be doing this 
> > anyway. Any fix that I can do? 
> > -Chris 
> > -- 
> > -------------------------------------------------------------------- 
> >Christopher N. Deckard 	 | Lead Web Systems Developer 
> >cnd@ecn.purdue.edu     	 | Engineering Computer Network 
> ><http://www.ecn.purdue.edu/> | Purdue University 
> >---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') --- 


------_=_NextPart_001_01C100BF.2CD5FEE0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Re: strange 'print' behavior in Python Scripts </TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>I have no idea why Python Scripts is acting this =
way.&nbsp; Can you generate your xml without</FONT>
<BR><FONT SIZE=3D2>using triple quotes?</FONT>
</P>

<P><FONT SIZE=3D2>print 'foo\nbar'</FONT>
</P>

<P><FONT SIZE=3D2>or </FONT>
</P>

<P><FONT SIZE=3D2>print '%s\n%s' % ('foo', 'bar')</FONT>
</P>

<P><FONT SIZE=3D2>--</FONT>
<BR><FONT SIZE=3D2>Patrick Lewis</FONT>
</P>

<P><FONT SIZE=3D2>&quot;Christopher N. Deckard&quot; wrote:</FONT>
<BR><FONT SIZE=3D2>&gt; Clarification, this happens when using triple =
quotes</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; print ''' </FONT>
<BR><FONT SIZE=3D2>&gt; foo </FONT>
<BR><FONT SIZE=3D2>&gt; bar </FONT>
<BR><FONT SIZE=3D2>&gt; ''' </FONT>
<BR><FONT SIZE=3D2>&gt;</FONT>
<BR><FONT SIZE=3D2>&gt; Actually prints: </FONT>
<BR><FONT SIZE=3D2>&gt; foo </FONT>
<BR><FONT SIZE=3D2>&gt; bar </FONT>
<BR><FONT SIZE=3D2>&gt;</FONT>
<BR><FONT SIZE=3D2>&gt;-Chris </FONT>
<BR><FONT SIZE=3D2>&gt;</FONT>
<BR><FONT SIZE=3D2>&gt; &gt;&quot;Christopher N. Deckard&quot; wrote: =
</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; I'm running into problems because Zope is =
printing a space (&quot; &quot;) at the </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; beginning of each line when 'print'ing =
from a Python Script. I'm trying </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; to print out XML to a Java Applet and the =
Applet isn't smart enough to </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; take this into account. Bad parser, but =
Zope shouldn't be doing this </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; anyway. Any fix that I can do? </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; -Chris </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; -- </FONT>
<BR><FONT SIZE=3D2>&gt; &gt; =
-------------------------------------------------------------------- =
</FONT>
<BR><FONT SIZE=3D2>&gt; &gt;Christopher N. Deckard =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Lead Web Systems Developer =
</FONT>
<BR><FONT SIZE=3D2>&gt; &gt;cnd@ecn.purdue.edu&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Engineering Computer Network =
</FONT>
<BR><FONT SIZE=3D2>&gt; &gt;&lt;<A HREF=3D"http://www.ecn.purdue.edu/" =
TARGET=3D"_blank">http://www.ecn.purdue.edu/</A>&gt; | Purdue =
University </FONT>
<BR><FONT SIZE=3D2>&gt; &gt;---- =
zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)&quot;\005w') --- =
</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C100BF.2CD5FEE0--